from itertools import permutations

D = [int(input()) for _ in range(5)]
ans = 650

for d in list(permutations(D)):
  sum = 0
  for i in range(5):
    sum += d[i]
    if D[i] % 10 > 0:
      sum += 10 - (D[i] % 10)
    else:
      sum += 0
  if sum < ans:    
    ans = sum

print(ans)  