program abc10
 implicit none
 integer,allocatable::X(:)
 integer::N,i,K,s
 read(*,*)N
 allocate(X(N))
 read(*,'(bN)')K
 do i=1,N
  s=0
  if(ibits(K,N-i,1)==0)then
   X(i)=K+2**(N-i)
  else
   X(i)=K-2**(N-i)
  end if
  do while(X(i)>0)
   X(i)=mod(X(i),popcnt(X(i)))
   s=s+1
  end do
 print'(i0)',s
 end do
 deallocate(X)
end program abc10