// inputに入力データ全体が入る
function Main(input) {
  "use strict";
	const lines = input.split("\n");
  let nums = lines.map(s => parseInt(s, 10));
  nums.pop()

  const smallest_digit1 = nums.reduce((acc, n) => {
    const x1 = acc%10 || 10;
    const x2 = n%10 || 10;
    return x1 <= x2 ? acc : n
  }, 10);
  let find = false;
  const rest = nums.filter(n => {
    if (n === smallest_digit1  && !find) {
      find = true;
      return false
    }
    return true

  })
  const answer = rest.reduce((acc, n) => {
    return acc + n + ( n%10 === 0 ? 0 : 10 - n%10)
  }, 0) + smallest_digit1;
	//出力
  console.log(answer)
}
// Exec
Main(require("fs").readFileSync("/dev/stdin", "utf8"));