dish = [0]*5
dish = [list(input()) for i in range(len(dish))]
time = 0
sumtime = 0

dish_sort = sorted(dish, key=lambda x:abs(1-int(x[-1])),reverse=True)
dish_sort = [''.join(dish_sort[i]) for i in range(len(dish))]
dish_sort = [int(i) for i in dish_sort]

for i in range(len(dish)-1):
    while dish_sort[i] > time:
        time += 10
    sumtime += time
    time = 0
print(sumtime+dish_sort[-1])