def calc(x,c,i)
  y = x%c
  return i if y==0
  z = y.to_s(2)
  c = z.count('1')
  calc(y,c,i+1)
end

n = gets.to_i
x = gets.chomp
popcnt = x.count('1')

n.times{|i|
  s = x.dup
  c = popcnt
  if s[i]=='0'
    s[i] = '1'
    c+=1
  else
    s[i] = '0'
    c-=1
  end
  y = s.to_i(2)
  
  p calc(y,c,1)
}

