import sys

n=int(eval(input()))

s=eval(input())

frac=[0]*(n+1)

for i in range(1,n+1):

    k=i

    frac[i]=frac[i-1]

    while k%2==0:

        k//=2

        frac[i]+=1



ans=0

for i in range(n):

    if int(s[i])==2 and frac[n-1]-frac[i]-frac[n-1-i]==0:

        ans^=1



if ans==1: print((1))

elif "2" in s: print((0))

else:

    ans=0

    for i in range(n):

        if int(s[i])==3 and frac[n-1]-frac[i]-frac[n-1-i]==0:

            ans^=1

    print((ans*2))

import sys

n=int(eval(input()))

s=eval(input())

frac=[0]*(n+1)

for i in range(1,n+1):

    k=i

    frac[i]=frac[i-1]

    while k%2==0:

        k//=2

        frac[i]+=1



if "2" in s: p=2

else: p=3



ans=0

for i in range(n):

    if int(s[i])==p and frac[n-1]-frac[i]-frac[n-1-i]==0:

        ans^=1

print((ans if p==2 else ans*2))
import sys

n = int(eval(input()))
s = eval(input())
frac = [0] * (n + 1)
for i in range(1, n + 1):
    k = i
    frac[i] = frac[i - 1]
    while k % 2 == 0:
        k //= 2
        frac[i] += 1
ans = 0
for i in range(n):
    if int(s[i]) == 2 and frac[n - 1] - frac[i] - frac[n - 1 - i] == 0:
        ans ^= 1
if ans == 1:
    print((1))
elif "2" in s:
    print((0))
else:
    ans = 0
    for i in range(n):
        if int(s[i]) == 3 and frac[n - 1] - frac[i] - frac[n - 1 - i] == 0:
            ans ^= 1
    print((ans * 2))

import sys

n = int(eval(input()))
s = eval(input())
frac = [0] * (n + 1)
for i in range(1, n + 1):
    k = i
    frac[i] = frac[i - 1]
    while k % 2 == 0:
        k //= 2
        frac[i] += 1
if "2" in s:
    p = 2
else:
    p = 3
ans = 0
for i in range(n):
    if int(s[i]) == p and frac[n - 1] - frac[i] - frac[n - 1 - i] == 0:
        ans ^= 1
print((ans if p == 2 else ans * 2))

+if "2" in s: +    p = 2 +else: +    p = 3 -    if int(s[i]) == 2 and frac[n - 1] - frac[i] - frac[n - 1 - i] == 0: +    if int(s[i]) == p and frac[n - 1] - frac[i] - frac[n - 1 - i] == 0: -if ans == 1: -    print((1)) -elif "2" in s: -    print((0)) -else: -    ans = 0 -    for i in range(n): -        if int(s[i]) == 3 and frac[n - 1] - frac[i] - frac[n - 1 - i] == 0: -            ans ^= 1 -    print((ans * 2)) +print((ans if p == 2 else ans * 2))