import numpy as np
order = [int(input()) for _ in range(5)]
first = []
rest = [0 for _ in range(5)]
for i in range(5):
    first.append(str(order[i])[-1:])
    first[i] = int(first[i])
    rest[i] = 10 - int(first[i])

first_arr = np.array(first)
first_arr = list(first_arr.argsort()[::-1])
rest_arr = np.array(rest)
rest_arr = list(rest_arr.argsort()[::-1])

time = 0
for i in range(4):
    time += order[first_arr[i]] + rest_arr[i]
    #print(order[first_arr[i]], time)

final_time = time + (10 - time%10)+ order[first_arr[4]]
print(final_time)