n = gets.to_i
x = gets.chomp
if x.size < n
  x = '0' * (n - x.size) + x
end
n.times do |i|
  y = x.dup
  y[i] = y[i] == '1' ? '0' : '1'
  popcount = y.count('1')
  ans = 0
  y = y.to_i(2)
  while y > 0
    y = y % popcount
    popcount = y.to_s(2).count('1')
    ans += 1
  end
  # puts  "#{i+1}, popcount: #{popcount}, mod: #{y % popcount}"
  # puts  "#{i+1}, #{ans}"
  p ans
end

