
Imports System.Console
Module Module1
    Dim n As Int64
    Dim xx As String
    Dim ans As Int64
    Sub Main()
        n = ReadLine()
        xx = ReadLine()
        For i = 1 To n
            Dim samp As Int64 = Repl(xx, i)
            Dim a As Integer = 1
            Dim w As Int64 = samp
            Do Until w = 0
                w = w Mod Popcount(w)
                a += 1
            Loop
            WriteLine(a - 1)
        Next
        ReadLine()
    End Sub
    Private Function Popcount(ByVal inf As Int64)
        Dim r As Int64
        Dim s As String = Convert.ToString(inf, 2)
        Dim ch() As Char = s.ToCharArray
        For i = 0 To s.Length - 1
            If ch(i) = "1" Then
                r += 1
            End If
        Next
        Return r
    End Function
    Private Function Repl(ByVal x As String, ByVal intt As Integer)
        Dim ch() As Char = x.ToCharArray
        If ch(intt - 1) = "0" Then
            Mid(x, intt, 1) = "1"
        Else
            Mid(x, intt, 1) = "0"
        End If
        Return Convert.ToInt64(x, 2)
    End Function
End Module
