n = gets.to_i
x = gets.chomp.chars
n.times do |i|
  y = x.dup
  if y[i] == '0'
    y[i] = '1'
  else
    y[i] = '0'
  end
  z = y.join('').to_i(2)
  b = y.count('1')
  c = 0
  while z > 0
    c += 1
    z %= b
    b = z.to_s(2).count('1')
  end
  puts c
end