def main():

    n = int(eval(input()))

    a = list([int(x)-1 for x in list(eval(input()))])

    b = [i % 2 for i in a]



    def all_a(x):

        ans = 0

        for j, i in enumerate(x):

            ans ^= (n-1 | j == n-1)*i

        return ans



    all_b = all_a(b)

    if all_b == 1:

        print((1))

        return

    if 1 in a:

        print((0))

        return

    b = [i//2 for i in a]

    print((all_a(b)*2))





main()
n,a=int(eval(input()))-1,list([int(x)-1 for x in list(eval(input()))]);b=[i%2for i in a]

def c(x):

 a=0

 for j,i in enumerate(x):a^=(n|j==n)*i

 return a

if c(b):k=1

elif 1in a:k=0

else:k=c([i//2for i in a])*2

print(k)
def main():
    n = int(eval(input()))
    a = list([int(x) - 1 for x in list(eval(input()))])
    b = [i % 2 for i in a]

    def all_a(x):
        ans = 0
        for j, i in enumerate(x):
            ans ^= (n - 1 | j == n - 1) * i
        return ans

    all_b = all_a(b)
    if all_b == 1:
        print((1))
        return
    if 1 in a:
        print((0))
        return
    b = [i // 2 for i in a]
    print((all_a(b) * 2))


main()

n, a = int(eval(input())) - 1, list([int(x) - 1 for x in list(eval(input()))])
b = [i % 2 for i in a]


def c(x):
    a = 0
    for j, i in enumerate(x):
        a ^= (n | j == n) * i
    return a


if c(b):
    k = 1
elif 1 in a:
    k = 0
else:
    k = c([i // 2 for i in a]) * 2
print(k)

-def main(): -    n = int(eval(input())) -    a = list([int(x) - 1 for x in list(eval(input()))]) -    b = [i % 2 for i in a] - -    def all_a(x): -        ans = 0 -        for j, i in enumerate(x): -            ans ^= (n - 1 | j == n - 1) * i -        return ans - -    all_b = all_a(b) -    if all_b == 1: -        print((1)) -        return -    if 1 in a: -        print((0)) -        return -    b = [i // 2 for i in a] -    print((all_a(b) * 2)) +n, a = int(eval(input())) - 1, list([int(x) - 1 for x in list(eval(input()))]) +b = [i % 2 for i in a] -main() +def c(x): +    a = 0 +    for j, i in enumerate(x): +        a ^= (n | j == n) * i +    return a + + +if c(b): +    k = 1 +elif 1 in a: +    k = 0 +else: +    k = c([i // 2 for i in a]) * 2 +print(k)