import numpy as np
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

A = list(str(a))
B = list(str(b))
C = list(str(c))
D = list(str(d))
E = list(str(e))

k = np.argmin([A[-1], B[-1], C[-1], D[-1], E[-1]])
sum = 0
if A[-1] == 0:
  sum += a
else:
  sum += a + (10 - int(A[-1]))
if B[-1] == 0:
  sum += b
else:
  sum += b + (10 - int(B[-1]))
if C[-1] == 0:
  sum += c
else:
  sum += c + (10 - int(C[-1]))
if D[-1] == 0:
  sum += d
else:
  sum += d + (10 - int(D[-1]))
if E[-1] == 0:
  sum += e
else:
  sum += e + (10 - int(E[-1]))
sum -= 10 - [A[-1], B[-1], C[-1], D[-1], E[-1]][k]
print(sum)