A = input()
B = input()
C = input()
D = input()
E = input()
L = [A,B,C,D,E]
#L_s = str(L)
m=9
for i in L:
    if(i[-1]!="0"):
        m=min(m,int(i[-1]))

ans=0
for i in L:
    if(i[-1]==str(m)):
        ans+=int(i)
        #print(i)
    else:
        ans+=int(i)
        if(i[-1]!="0"):
            ans+=10-int(i[-1])
print(ans)