A=[int(input()) for _ in range(5)]
A_1=[(i,i%10) for i in A]
A_1.sort(key=lambda x:x[1])
ans=0
count=0
for a,b in A_1:
    if not b==0 and count==0:
        count=b
    if b==0:
        ans+=a
    else:
        ans+=a+abs(10-b)

print(ans-abs(10-count))