import sys

input = sys.stdin.readline

foods = [int(input()) for _ in range(5)]

exist_remainder_list = [(food, food % 10) for food in foods if food % 10 != 0]

last = min(exist_remainder_list, key=lambda value: value[1])

foods.remove(last[0])

ans = 0

for index, food in enumerate(foods):
    ans += food
    while True:
        if ans % 10 == 0:
            break
        else:
            ans += 1

print(ans + last[0])
