N = [int(input()) for _ in range(5)]
A = []
B = []
C = []
for n in N:
    n = list(str(n))
    n.reverse()
    A.append(int(n[0]))
for a in A:
  if a == 0:
    B.append(100)
  else:
    B.append(a)
    C.append(10-a)
b = min(B)
if b == 100:
  b = 0
print(sum(N)+sum(C)-(10-b))