
dishes = [input() for _ in range(5)]

sum_dishes = 0
last_dish = 0
last_tmp = 0
for idx, dish in enumerate(dishes):
    tmp = 10 - int(dish[-1])
    dish = int(dish)
    if tmp == 10:
        sum_dishes += dish
    elif tmp > last_tmp:
        sum_dishes += last_dish + last_tmp
        last_dish = dish
        last_tmp = tmp
        last_idx = idx
    else:
        sum_dishes += dish + tmp

print(sum_dishes + int(dishes[last_idx]))
