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)

i = 0

for menu in menu_list:
    if menu[:1] == '0':
        total += int(menu[::-1])
        menu_list.pop(i)
    i += 1

menu_list.sort()
menu_list.reverse()

menu_time = 0

j = 0

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

    j += 1

print(total)