T = []
for i in range(5):
    T.append(input())
tmp = []
for i in range(5):
    tmp.append(10 - int(T[i][-1]))
minlist = []
for i in range(5):
    if tmp[i] > 4:
        minlist.append(tmp[i])
    else:
        minlist.append(10)
last = tmp.index(min(minlist))
tmp2 = [0 if x == 10 else x for x in tmp]
ans = []
for i in range(5):
    ans.append(tmp2[i] + int(T[i]))
print(sum(ans) - ans[last] + int(T[last]))