from sys import stdin

def ten(x):
    return 10 - x

lst = []
for i in range(5):
    a = int(stdin.readline().rstrip())
    lst.append(a)

minv = 9
flag = False
for x in lst:
    s = str(x)
    tmp = int(s[-1])
    if tmp < minv and tmp != 0:
        flag = True
        minv = tmp

sum = 0

for x in lst:
    s = str(x)
    tmp = int(s[-1])
    if tmp >= 1:
        tmp2 = ten(tmp)
        sum = sum + x + tmp2
    else:
        sum = sum + x

if minv != 0 and flag:
    sum = sum - (ten(minv))

print(sum)
