a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
menu=[a,b,c,d,e]
time=0
for i in ["1","2","3","4","5","6","7","8","9","0"]:
    if i in [str(a)[-1],str(b)[-1],str(c)[-1],str(d)[-1],str(e)[-1]]:
        mi=[str(a)[-1],str(b)[-1],str(c)[-1],str(d)[-1],str(e)[-1]].index(i)
        break
minu=menu[mi]
for i in menu:
    if i!=minu:
        time+=i
        while time%10!=0:
            time+=1
time+=minu
print(time)