T = [int(input()) for _ in range(5)]

ans = 643

for i0 in range(5):
  tmp = i0
  tmp += (10-tmp)//10
  l = range(5)
  l.remove(i0)
  for i1 in l:
    tmp += i1
    tmp += (10-tmp)//10
    l.remove(i1)
    for i2 in l:
      tmp += i2
      tmp += (10-tmp)//10
      l.remove(i2)
      for i3 in l:
        tmp += i3
        tmp += (10-tmp)//10
        l.remove(i3)
        for i4 in l:
          tmp += i4
          ans = min(ans,tmp)
print(ans)