def sub():
    items = [int(input()) for _ in range(5)]
    ms = [e % 10 for e in items]

    minIdx = None
    minMod = 11
    for i, m in enumerate(ms):
        if m == 0:
            continue
        if m < minMod:
            minMod = m
            minIdx = i
    if minIdx is None:
        print(sum(items))
        return
    others = items[:minIdx] + items[minIdx+1:]
    cum = 0
    for a in others:
        m = a % 10
        if m == 0:
            cum = cum + a
        else:
            cum = cum + (10 - m)
    cum = cum + items[minIdx]
    print(cum)

sub()
