import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val c = sc.nextInt()
    val d = sc.nextInt()
    val e = sc.nextInt()
    val cookings = listOf(e, d, c, b, a).sortedDescending()
    val result = cooking(cookings, 0)
    println(result)
}


private fun cooking(list: List<Int>, time: Int): Int {
    val cook = list.maxBy {
        val a = (it % 10)
        return@maxBy if (a == 0) {
            10
        } else a
    }?: return time
    val (list1, list2) = list.partition { it == cook }
    val newList = choiceList(list1, list2)
    if (newList.isEmpty()) {
        return time + cook
    } else {
        val calc = if (cook % 10 == 0) 0 else 10 - (cook % 10)
        return cooking(newList, time + cook + calc)
    }
}

private fun choiceList(list1: List<Int>, list2: List<Int>): List<Int> {
    return if (list2.isEmpty()) {
        list1.take(list1.size - 1)
    } else {
        list2
    }
}