import itertools
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def time(n):
  t = 0
  if n % 10 == 0:
    t = 0
  else:
    t = 10 - n % 10
  return t

dic = {a: time(a), b:time(b), c:time(c), d:time(d), e:time(e)}
dic = sorted(dic.items(), key=lambda x:x[1])
dic = list(itertools.chain.from_iterable(dic))
print(sum(dic[:-1]))