time = []
mod_5 = []

for i in range(5):
    t = int(input())
    time.append(t)
    mod_5.append(t % 5)

flag = False
min_mod = min(mod_5)

for i in range(5):
    if mod_5[i] == min_mod and not flag:
        flag = True
    else:
        time[i] = ((time[i] + 4) // 5) * 5

print(sum(time))