function main(input) {
  const n = parseInt(input[0]);
  const x = {};
  x.two = input[1];
  x.ten = parseInt(x.two, 2);

  const popcount = x.two.split("").reduce((acc, value) => {
    return ((value==1)?(acc+1):(acc));
  }, 0);

  for(let i=0;i<n;i++){
    const k = JSON.parse(JSON.stringify(x));
    let new_k = k.two.split("");
    if(new_k[i]==="0"){
      new_k[i]=1;
    }else{
      new_k[i]=0;
    }
    k.two = new_k.join("");
    k.ten = parseInt(k.two, 2);

    let cnt = 0;

    while(k.ten !== 0){
      const popcount = k.two.split("").reduce((acc, value) => {
        return ((value==1)?(acc+1):(acc));
      }, 0);
      k.ten = k.ten % popcount;
      k.two = k.ten.toString(2);
      cnt++;
    }
    console.log(cnt);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));