def popcount_parity(x):

    x ^= x >> 1

    x ^= x >> 2

    x ^= x >> 4

    x ^= x >> 8

    x ^= x >> 16

    x ^= x >> 32

    x ^= x >> 64

    x ^= x >> 128

    x ^= x >> 256

    x ^= x >> 512

    x ^= x >> 1024

    x ^= x >> 2048

    x ^= x >> 4096

    x ^= x >> 8192

    x ^= x >> 16384

    x ^= x >> 32768

    x ^= x >> 65536

    x ^= x >> 131072

    x ^= x >> 262144

    x ^= x >> 524288

    return x & 1



N = int(eval(input())) - 1

s = 1

while N:

    l = N & -N

    s *= 1 + (1 << l)

    N ^= l



A = eval(input())

if "2" in A:

    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)

    print((popcount_parity(a & s)))

else:

    a = int(A.replace("1", "0").replace("3", "1"), 2)

    print((popcount_parity(a & s) * 2))
def popcount_parity(x):

    x ^= x >> 1

    x ^= x >> 2

    x ^= x >> 4

    x ^= x >> 8

    x ^= x >> 16

    x ^= x >> 32

    x ^= x >> 64

    x ^= x >> 128

    x ^= x >> 256

    x ^= x >> 512

    x ^= x >> 1024

    x ^= x >> 2048

    x ^= x >> 4096

    x ^= x >> 8192

    x ^= x >> 16384

    x ^= x >> 32768

    x ^= x >> 65536

    x ^= x >> 131072

    x ^= x >> 262144

    x ^= x >> 524288

    return x & 1



N = int(eval(input())) - 1

s = 1

while N:

    l = N & -N

    s |= s << l

    N ^= l



A = eval(input())

if "2" in A:

    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)

    print((popcount_parity(a & s)))

else:

    a = int(A.replace("1", "0").replace("3", "1"), 2)

    print((popcount_parity(a & s) * 2))
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    x ^= x >> 32
    x ^= x >> 64
    x ^= x >> 128
    x ^= x >> 256
    x ^= x >> 512
    x ^= x >> 1024
    x ^= x >> 2048
    x ^= x >> 4096
    x ^= x >> 8192
    x ^= x >> 16384
    x ^= x >> 32768
    x ^= x >> 65536
    x ^= x >> 131072
    x ^= x >> 262144
    x ^= x >> 524288
    return x & 1


N = int(eval(input())) - 1
s = 1
while N:
    l = N & -N
    s *= 1 + (1 << l)
    N ^= l
A = eval(input())
if "2" in A:
    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
    print((popcount_parity(a & s)))
else:
    a = int(A.replace("1", "0").replace("3", "1"), 2)
    print((popcount_parity(a & s) * 2))

def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    x ^= x >> 32
    x ^= x >> 64
    x ^= x >> 128
    x ^= x >> 256
    x ^= x >> 512
    x ^= x >> 1024
    x ^= x >> 2048
    x ^= x >> 4096
    x ^= x >> 8192
    x ^= x >> 16384
    x ^= x >> 32768
    x ^= x >> 65536
    x ^= x >> 131072
    x ^= x >> 262144
    x ^= x >> 524288
    return x & 1


N = int(eval(input())) - 1
s = 1
while N:
    l = N & -N
    s |= s << l
    N ^= l
A = eval(input())
if "2" in A:
    a = int(A.replace("1", "0").replace("3", "0").replace("2", "1"), 2)
    print((popcount_parity(a & s)))
else:
    a = int(A.replace("1", "0").replace("3", "1"), 2)
    print((popcount_parity(a & s) * 2))

-    s *= 1 + (1 << l) +    s |= s << l