import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val menus = List.fill(5)(sc.nextInt())

    val a = menus.zip(menus.map(_ % 10).map{b =>
      if (b == 0) 0 else 10 - b
    }).sortWith((A, B) => A._2 > B._2)
    println(a)
    val times = a.head._1 + a.tail.map{ case (c, d) => c + d }.sum
    println(times)
  }

}
