fun main(args: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val d = readLine()!!.toInt()
    val e = readLine()!!.toInt()
    var min = 9
    var changed = false
    var sum = 0
    intArrayOf(a,b,c,d,e).forEach { i ->
        run {
            val mod = i % 10
            if (mod in 1..(min - 1)) {
                min = mod
                changed = true
            }
            sum += i + if (mod == 0) mod else (10 - mod)
        }
    }
    println(sum + if (changed) min - 10 else 0 )
}