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

sum_dishes = []
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.append(dish)
    elif tmp > last_tmp:
        sum_dishes.append(last_dish + last_tmp)
        last_dish = dish
        last_tmp = tmp
        last_idx = idx
    else:
        sum_dishes.append(dish + tmp)

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