import itertools
def ABC123B():
    T = [int(input()) for _ in range(5)]
    templist = itertools.permutations(T)
    mint = 644
    for l in templist:
        time = 0

        for t in l:
            if time % 10 !=0:
                time += 10 - time % 10
            time += t

        mint = min(mint, time)
    print(time)


ABC123B()
