fun main(omkar: Array<String>) {
    val n = readLine()!!.toInt()
    val digits = readLine()!!.map { it - '1' }
    if (digits.contains(1)) {
        var parity1 = 0
        var chooseDiv = 0
        for (j in 0 until n) {
            if (j != 0) {
                var k = n - j
                while (k % 2 == 0) {
                    chooseDiv++
                    k /= 2
                }
                k = j
                while (k % 2 == 0) {
                    chooseDiv--
                    k /= 2
                }
            }
            if (digits[j] == 1 && chooseDiv == 0) {
                parity1 = 1 - parity1
            }
        }
        println(parity1)
    } else {
        var parity2 = 0
        var chooseDiv = 0
        for (j in 0 until n) {
            if (j != 0) {
                var k = n - j
                while (k % 2 == 0) {
                    chooseDiv++
                    k /= 2
                }
                k = j
                while (k % 2 == 0) {
                    chooseDiv--
                    k /= 2
                }
            }
            if (digits[j] == 2 && chooseDiv == 0) {
                parity2 = 2 - parity2
            }
        }
        println(parity2)
    }
}