a=[0,0,0,0,0]
b=[0,0,0,0,0]
time=0
cnt=0
a[0]=int(input())
a[1]=int(input())
a[2]=int(input())
a[3]=int(input())
a[4]=int(input())
for i in range(5):
  b[i]=a[i]%10
for i in range(10):
  for j in range(5):
    if b[j]==0:
      time=time+a[j]
      a[j]=0
      cnt=cnt+1
    elif b[j]==(10-i):
      time=time+a[j]+i
      cnt=cnt+1
      a[j]=0
      if cnt==5:
        time=time-i
print(time)