func main() {
    let n = Int(readLine()!)!
    let x = Int(readLine()!, radix: 2)!
    func calculate(num: Int) -> Int {
        var count = 0
        var it = num
        while it > 0 {
            it %= it.nonzeroBitCount
            count += 1
        }
        return count
    }
    var new: Int
    for it in 1...n {
        new = x ^ (1 << (n-it))
        print(calculate(num: new))
    }
}

main()
