import numpy as np
import itertools
data = [int(input()) for _ in range(5)]

for orders in itertools.permutations(data):
    current_time = 0
    next_arrival = 0
    for i in range(5):
        next_arrival = current_time + orders[i]
        current_time = np.ceil(next_arrival/10).astype(int) *10
print(next_arrival)