import itertools
List=[int(input()) for i in range(5)]
List_2=list(itertools.permutations(List))
min = 100000
for i in List_2:
  time = 0
  for j in i:
    if j != i[len(i)-1]:
      time += j
      if time % 10 != 0:
        time = ((time // 10) + 1) * 10  
    elif j == i[len(i) -1] :
      time += j
  if time < min:
    min = time
print(min)
