import java.util.*


fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    solve(n, s)
}




private fun solve(n: Int, s: String) {
    val list = IntArray(s.length)
    var hasOne = false

    for (i in s.indices) {
        val d = s[i] - '0'
        list[i] = d - 1
        if(list[i] == 1) {
            hasOne = true
        }
    }
    var cnt = 0
    for(i in 0 until n) {
        val l = n - 1 - i
        val r = i
        if((l xor r) != n-1) continue
        cnt += if(hasOne) {
            if(list[i] == 1) 1 else 0
        } else {
            list[i] / 2
        }
    }
    if(cnt % 2 == 0)
        print(0)
    else {
        if(hasOne)
            print(1)
        else
            print(2)
    }
}

