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

dish_sort = sorted(dish, key=lambda x:x[-1])
dish_sort = [''.join(dish_sort[i]) for i in range(len(dish))]
dish_sort1 = [int(i) for i in dish_sort]
dish_sort2 = [i for i in dish_sort1 if not i%10==0]
dish_sort1.remove(dish_sort2[0])

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