const main = stdin => {
  const dishes = [A, B, C, D, E] = stdin.trim().split('\n').map((x) => parseInt(x))

  let time = 999999

  for (let i = 0; i < 5; i++) {
    for (let j = 0; j < 5; j++) {
      if (i === j) continue
      for (let k = 0; k < 5; k++) {
        if (i === k || j === k) continue
        for (let l = 0; l < 5; l++) {
          if (i === l || j === l || k === l) continue
          for (let m = 0; m < 5; m++) {
            if (i === m || j === m || k === m || l === m) continue
            let tmpTime = dishes[i];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[j];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[k];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[l];
            if (tmpTime % 10 !== 0) {
              tmpTime += 10 - tmpTime % 10
            }
            tmpTime += dishes[m];

            time = Math.min(time, tmpTime)
          }
        }
      }
    }
  }

  console.log(time)
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))
