object Main extends App {
  val a = io.StdIn.readInt // don
  val b = io.StdIn.readInt // curry
  val c = io.StdIn.readInt // pasta
  val d = io.StdIn.readInt // ramen
  val e = io.StdIn.readInt // hamba-gu

  // 数を10の倍数になるまで繰り上げる
  def multiple(n: Int): Int = n match {
    case int if int%10 == 0 => int
    case int => multiple(n+1)
  }

  val array = Array(a,b,c,d,e)
  val multiples = array.map(multiple(_))
  val diffs = (array zip multiples).map(t => t._2 - t._1)
  val diff_max = diffs.max
  val last_dish = array.filter(dish => multiple(dish) - dish == diff_max).head
  val result = multiples.sum - multiple(last_dish) + last_dish
  println(result)
}