time = []
for _ in range(5):
    time.append(int(input()))

mod = []
for i in time:
    mod.append(i % 10)

mod = [i for i in mod if i != 0]

for i in range(len(mod)):
    mod[i] = 10 - mod[i]

add = sum(mod) - max(mod)

print(sum(time) + add)