time=[];timeloss=[];ans=0
for i in range(5):
    a=input()
    if a[-1]==0:
        ans+=int(a)
    else:
        time.append(int(a))
        timeloss.append(10-int(a[-1]))
for i in range(5):
        for i in range(5):
            if timeloss[i]==min(timeloss):
                ans+=time[i]
                if not len(time)==1:
                    ans+=timeloss[i]
                del time[i];del timeloss[i];break
print(ans)