n = []
for i in range(5):
    a = input()
    n.append(a)
m = 10-min(int(n[0][-1]),int(n[1][-1]),int(n[2][-1]),int(n[3][-1]),int(n[4][-1]))
a = []
for i in n:
    a.append(10 - int(i[-1]))
total = 0
for i in n:
    total += int(i)
print(sum(a) + total - m)
