list1 = []
for i in range(5):
  a = input()
  b = int(a[-1])
  c = int(a)
  list1.append((b,c))
aaa = sorted(list1)

mini = []
total = 0
for i in range(5):
  if aaa[i][0] != 0:
    mini = aaa[i]
    
    a = aaa.pop(i)
    break

for i in aaa:
  if i[0] != 0:
    d = 10 - i[0]
    ans = i[1] + d
  else:
    ans = i[1]
  total += ans
try:
  total += mini[1]
except:
  total = 0
print(total)
    