import itertools

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

X = [A, B, C, D, E]

def calc_time(cand):
  tm = 0
  for i in range(len(cand)):
    tm += cand[i]
    if i < 4:
      if tm % 10 != 0:
        tm += 10 - tm % 10
  return(tm)

res = 10000
for cand in itertools.permutations(X):
  tm = calc_time(cand)
  if tm < res:
    res = tm
print(tm)