def round_up(n: int) -> int:
    if n%10 != 0:
        return n + 10 - (n%10)
    else:
        return n

def round_up_count(n: int) -> int:
    if n%10 != 0:
        return 10 - n%10
    else:
        return 0

orders = []

max_rc: int = 0
last_order_index: int = 0
last_order_time: int = 0

for i in range(5):
    order = int(input())
    orders.append(order)
    last_order_time += round_up(order)
    rc = round_up_count(order)
    if max_rc <= rc:
        last_order_index = i
        max_rc = rc

print(last_order_time - round_up_count(orders[last_order_index]))