a = input()[::-1]
b = input()[::-1]
c = input()[::-1]
d = input()[::-1]
e = input()[::-1]

total = 0

menu_list = []

menu_list.append(a)
menu_list.append(b)
menu_list.append(c)
menu_list.append(d)
menu_list.append(e)

menu_list2 = []

for i in range(len(menu_list)):
    if menu_list[i][:1] == '0':
        total += int(menu_list[i][::-1])
    else:
        menu_list2.append(menu_list[i])

menu_list.sort()
menu_list.reverse()

menu_time = 0

j = 0

for menu2 in menu_list2:
    menu_time = int(menu2[::-1])
    
    if j == len(menu_list2)-1:
        total += menu_time
    else:
        total += menu_time + 10 - menu_time % 10

    j += 1

print(total)