A = []
for i in range(5):
  A.append(input())
B = {}
x = 0
for i in A:
  B[i[-1]] = x
  x += 1

keys = []
for key, value in B.items():
    keys.append(int(key))

p1 = 0
if 0 in keys:
    keys.remove(0)
    p1 = min(keys)
else:
    p1 = min(keys)

we = A.pop(B[str(p1)])

cnt = 0
for i in A:
    if i[-1] != 0:
        C = 10 - int(i[-1])
        cnt += C+int(i)
    else:
        cnt += int(i)
 

print(cnt + int(we))
