dishes = []
for i in range(5):
    dishes.append(int(input()))
    
ma = 0
fills = []
for dish in dishes:
    fill = 10 - dish % 10
    if fill > ma and fill != 10:
        ma = fill
        max_dish = dish
    
    fills.append(fill)

flag = True
if len(set(fills)) == 1:
    flag = False

if flag:
    sum_dish = 0
    for idx, dish in enumerate(dishes):
        if dish == max_dish:
            sum_dish += dish
        elif dish % 10 == 0:
            sum_dish += dish
        else:
            sum_dish += (dish + fills[idx])
else:
    sum_dish = 0
    for dish in dishes:
        sum_dish += dish
    sum_dish += 4 * fills[0]

print(sum_dish)