io = DATA.eof? ? STDIN : DATA
n=io.gets.to_i
x=io.gets.to_i(2)
def popcount(x)
  b = 0
  while x > 0
    x &= x - 1
    b += 1
  end
  return b
end
def f(n)
  return 1 if n==0
  cnt=1
  while ((pc=popcount(n))>0&&n=(n % pc)) > 0
    cnt+=1
  end
  cnt+1
end
pcx=popcount(x)
pc0,pc1= pcx+1,pcx-1
xmod0=x%pc0
xmod1=x%pc1
n.downto(1) do |i|
  bit =  (1 << (i-1))
  pci,xmodi = (x&bit) ==0 ? [pc0,xmod0] : [pc1,xmod1]
  if pci==0
    puts 0
  else
    n=((xmodi)^(bit%pci))%pci
    puts f(n)
  end
end
__END__
