# AtCoder

lst = [int(input()) for _ in range(5)]

n = len(lst)
diffs = []
for i in range(n):
    dif = 10 - int(str(lst[i])[-1])
    diffs.append(dif)

s = []
for i in diffs:
    if i == 10:
        continue
    s.append(i)
mx = max(s)
s.remove(mx)
print(sum(s)+sum(lst))
