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 {
        let inverter = 1 << (n-it)
        let invertee = (x >> (n-it)) % 2
        if invertee == 1 {
            new = x - inverter
        } else {
            new = x + inverter
        }
        print(calculate(num: new))
    }
}
main()