A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
a=A%10
b=B%10
c=C%10
d=D%10
e=E%10
if a==0 :
    print(A+B+C+D+E+40-a-b-c-d-e+min(b,c,d,e))
elif b==0 :
    print(A+B+C+D+E+40-a-b-c-d-e+min(a,c,d,e))
elif c==0 :
    print(A+B+C+D+E+40-a-b-c-d-e+min(b,a,d,e)) 
elif d==0 :
    print(A+B+C+D+E+40-a-b-c-d-e+min(b,a,c,e)) 
elif e==0 :
    print(A+B+C+D+E+40-a-b-c-d-e+min(b,a,d,c)) 
else :
    print(A+B+C+D+E+40-a-b-c-d-e+min(b,a,d,e,c))        