def mod(x):
  if x % 10 == 0:
    return x
  else:
    while True:
      x += 1
      if x % 10 == 0:
        break
    return x
      
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
M = min(A%10, B%10, C%10, D%10, E%10)

if M = A%10:
  ans = A + mod(B) + mod(C) + mod(D) + mod(E)
elif M = B%10:
  ans = mod(A) + B + mod(C) + mod(D) + mod(E)
elif M = C%10:
  ans = mod(A) + mod(B) + C + mod(D) + mod(E)
elif M = D%10:
  ans = mod(A) + mod(B) + mod(C) + D + mod(E)
else:
  ans = mod(A) + mod(B) + mod(C) + mode(D) + E