N=gets.to_i
X=gets.to_i(2)

def popcount(n)
    n.to_s(2).count('1')
end

def f(n)
    count = 0
    while n != 0
        count += 1
        # p [n,popcount(n)]
        n = n % popcount(n)
    end
    count
end

1.upto(N) do |i|
    x = X
    x = x ^ (1<<N-i)
    puts f(x)
end