fun main(args: Array<String>) {
    val N = nextInt()
    val A = next().map { it - '0' - 1 }
    if (A.all { it == A[0] }) return println(0)
    fun solve(a: List<Int>): Int {
        var two = 0
        var res = 0
        val n = a.size - 1
        a.forEachIndexed { i, v ->
            if (two == 0) res = res xor v
            two += Integer.numberOfTrailingZeros(n - i) - Integer.numberOfTrailingZeros(i + 1)
        }
        return res
    }
    val ans = if (A.contains(1)) solve(A.map { it % 2 }) else solve(A.map { it / 2 }) * 2
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
