l = []
for i in range(5):
    l.append(int(input()))

ans = 10**10

import itertools
t = 0
for P in itertools.permutations(l,len(l)):
    for p in P:
        t += p
        if (p % 10) != 0:
            tt = 10-p%10
            t += (10 - p%10)


    ans = min(ans , t-tt)
    t = 0
print(ans)
