import scala.io.StdIn._

object Main extends App {

  val D = Array.fill(5)(readInt())

  def solve() = {
    val lastDishIndex = D.zipWithIndex.collect {
      case (minutes, i) if minutes % 10 != 0 => (minutes % 10, i)
    }.sortBy(_._1).map(_._2).headOption
    lastDishIndex match {
      case None => D.sum
      case Some(idx) => {
        D.zipWithIndex.foldLeft(0) { case (acc, (minutes, i)) =>
          if(i == idx) acc + D(i)
          else acc + D(i) + losTime(D(i))
        }
      }
    }
  }

  def losTime(t: Int): Int = {
    if(t % 10 == 0) 0
    else 10 - (t % 10)
  }

  println(solve())

}

