a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cost_list = [a, b, c, d, e]

min_cost = 100
ans = 0
for cost in cost_list:
    wait_cost = cost % 10

    if wait_cost < min_cost and wait_cost != 0:
        min_cost = wait_cost

    wait_next_order = 0
    if wait_cost != 0:
        wait_next_order = 10 - wait_cost

    ans += cost + wait_next_order

max_wait_cost = 0
if min_cost != 0:
    max_wait_cost = 10 - min_cost
print(ans - max_wait_cost)