dish = [input() for i in range(5)]

a = []

for i in range(5):
    a.append(int(dish[i][-1]))

r = []

for i in range(5):
    r.append(int(dish[i]))

for i in range(5):
    if i != a.index(min(a)):
    
        r[i] += 10 - a[i]

print(sum(r))
    
    