T = [int(input()) for _ in range(5)]
 
ans = 643
 
for i0 in range(5):
  tmp = T[i0]
  tmp += (10-tmp)%10
  l = [0,1,2,3,4]
  l.remove(i0)
  for i1 in l:
    tmp += T[i1]
    tmp += (10-tmp)%10
    l.remove(i1)
    for i2 in l:
      tmp += T[i2]
      tmp += (10-tmp)%10
      l.remove(i2)
      for i3 in l:
        tmp += T[i3]
        tmp += (10-tmp)%10
        l.remove(i3)
        for i4 in l:
          tmp += T[i4]
          ans = min(ans,tmp)
print(ans)