object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(5)(sc.nextInt()).sortBy(i => (i - 1) % 10)
  val f = (i: Int) => i + (if (i % 10 == 0) 0 else 10 - i % 10)
  println(xs.map(f).sum + x)
}
