fun main(args: Array<String>) {
    val t = Array(5) {
        readLine()!!.toInt()
    }.toList()

    println(f(t))
}

private fun f(t: List<Int>) : Int {

    fun orderTime(current: Int, order: Int) : Int {
        val m = current % 10
        if (m > 0) {
            return order + current + 10 - m
        }
        return order + current
    }

    fun g(orders: List<Int>, order: Int, current: Int) : Int {
        val time = orderTime(current, order)
        val rest = orders.toMutableList()
        rest.remove(order)
        if (rest.isEmpty()) {
            return time
        }

        var min = Int.MAX_VALUE
        for (nextOrder in rest) {
            min = Math.min(g(rest, nextOrder, time), min)
        }

        return min
    }

    var min = Int.MAX_VALUE

    for (order in t) {
        min = Math.min(g(t, order, 0), min)
    }

    return min
}