l = []
for i in range(5):
    l.append(int(input()))
amari = []
for i in range(5):
    amari.append(10-l[i]%10)
jikan = []
for i in range(5):
    jikan.append(l[i] + amari[i])
print(sum[jikan]-max(amari))
