$cache = {}
input = defined?(DATA) ? DATA : STDIN
n = input.gets.to_i
x = input.gets.to_i(2)
(n - 1).downto(0) do |i|
  xi = x ^ (1 << i)
  count = 0
  while xi > 0
    count += 1
    if $cache[xi]
      xi = $cache[xi]
    else
      bits = 0
      xi.bit_length.times do |j|
        bits += xi[j]
      end
      mod = xi % bits
      $cache[xi] = mod
      xi = mod
    end
  end
  puts count
end
