n = 5.times.map { gets.to_i }
m = n.permutation(5).map { |a,b,c,d,e|
  t = 0

  t += a
  i,j = t.divmod(10)
  t = (j == 0)? i * 10 : (i+1) * 10

  t += b
  i,j = t.divmod(10)
  t = (j == 0)? i * 10 : (i+1) * 10

  t += c
  i,j = t.divmod(10)
  t = (j == 0)? i * 10 : (i+1) * 10

  t += d
  i,j = t.divmod(10)
  t = (j == 0)? i * 10 : (i+1) * 10

  t += e
  t
}

puts m.min