def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return list(map(int, ss_raw()))


def ceil(num):
    if int(str(num)[-1]) == 0:
        return num
    return num + 10 - int(str(num)[-1])


total = 0
minus = 0
times = []
for i in xrange(5):
    times.append(int_raw())

for time in times:
    if int(str(time)[-1]) == 0:
        local_minus = 0
    else:
        local_minus = 10 - int(str(time)[-1])
    minus = max(minus, local_minus)
    total += ceil(time)

total -= minus

print(total)
