A = input()
a = int(A[-1])
B = input()
b = int(B[-1])
C = input()
c = int(C[-1])
D = input()
d = int(D[-1])
E = input()
e = int(E[-1])
an = [A,B,C,D,E]
mi = [a,b,c,d,e]
mie = min(mi)
ans = 0
for i in range(5):
  if mi[i]!=mie:
    ans += int(an[i])+10-mi[i]
  else:
    ans += int(an[i])
print(ans)
  
