import itertools
args = []
for _ in range(5):
    tmp = int(input())
    args.append(tmp)
best = 643
for perm in itertools.permutations(args):
    remainder = 0
    cook = 0
    for t in perm:
        cook += t
        remainder += 10 - cook % 10
    else :
        remainder -= 10 - cook % 10
    cook += remainder
    if cook < best:
        best = cook
print(best)
