program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,j,cnt,ans,b,imod,l,l2,cnt2
    integer(int32):: bn,mn,mp,k
    integer(int32), allocatable:: mm(:,:)
    character(200000):: x

    read*, n
    read*, x

    bn=0; mn=0; mp=0
    do i=1,n
        if (x(i:i) == '1') bn=bn+1
    end do

    b=1
    do j=n,1,-1
        if (x(j:j) == '1') mn=mod(mn+b,bn-1)
        b=mod(b*2,bn-1)
    end do

    b=1
    do j=n,1,-1
        if (x(j:j) == '1') mp=mod(mp+b,bn+1)
        b=mod(b*2,bn+1)
    end do

    allocate(mm(n,2))
    mm(1,1) = mod(1,bn-1)
    mm(1,2) = mod(1,bn+1)

    do i=2,n
        mm(i,1) = mod(mm(i-1,1)*2,bn-1)
        mm(i,2) = mod(mm(i-1,2)*2,bn+1)
    end do

    print'(i0)', 1
    stop

    do i=1,n
        k = n+1-i
        if(x(i:i) == '1') then
            ans = bn-1
            imod = modulo(mn - mm(k,1), ans)
        else
            ans = bn+1
            imod = modulo(mp + mm(k,2), ans)
        end if
        cnt=0
        if (ans==0) then
            print'(i0)', 0
            cycle
        end if
        ans = imod
        cnt=1
        do while(ans /= 0)
            l = 0
            l2 = 1
            do while(l2 <= ans)
                l=l+1
                l2=l2*2
            end do
            cnt2 = 0
            do j=1,l
                if (btest(ans,j-1)) cnt2=cnt2+1
            end do
            ans = mod(ans,cnt2)
            cnt=cnt+1
        end do
        print'(i0)', cnt
    end do
end program main