Given is a sequence of N digits a_1a_2\ldots a_N, where each element is 1, 2, or 3. Let x_{i,j} defined as follows:

* x_{1,j} := a_j \quad (1 \leq j \leq N)
* x_{i,j} := | x_{i-1,j} - x_{i-1,j+1} | \quad (2 \leq i \leq N and 1 \leq j \leq N+1-i)



Find x_{N,1}.

Constraints

* 2 \leq N \leq 10^6
* a_i = 1,2,3 (1 \leq i \leq N)

Input

Input is given from Standard Input in the following format:


N
a_1a_2\ldotsa_N


Output

Print x_{N,1}.

Examples

Input

4
1231


Output

1


Input

10
2311312312


Output

0

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
N = int(input())
S = input()
a = [int(s) - 1 for s in S]
from collections import defaultdict
r = 1
d = defaultdict(int)
while 2 ** r <= N:
	for i in range(1, N):
		if i * 2 ** r <= N:
			d[i * 2 ** r] += 1
		else:
			break
	r += 1

def calc(list_of_int):
	length = len(list_of_int)
	res = list_of_int[0]
	keisu = 0
	for (i, r) in zip(list_of_int[1:], range(N - 1)):
		keisu += d[N - r - 1] - d[r + 1]
		res = (res + (2 if keisu > 0 else 1) * i) % 2
	return res
if 1 in a:
	print(calc(a))
else:
	print(calc(list(map(lambda x: x // 2, a))) * 2)


n = int(input())
al = list(input())
al = [int(a) - 1 for a in al]
flag = False
if 1 not in al:
	flag = True
	al = [a // 2 for a in al]
else:
	al = [a if a != 2 else 0 for a in al]
countl = [0]
a = 0
for i in range(1, n + 1):
	while i % 2 == 0:
		a += 1
		i //= 2
	countl.append(a)

def comb(a, b):
	if countl[a] - countl[a - b] - countl[b] > 0:
		return 0
	else:
		return 1
ans = 0
for (idx, a) in enumerate(al):
	if a == 1:
		ans += comb(n - 1, idx)
if ans % 2 == 0:
	print(0)
elif flag:
	print(2)
else:
	print(1)


N = int(input())
A = [int(a) - 1 for a in input()]
b = 1 if 1 in A else 2
ans = 0
for (i, a) in enumerate(A):
	if N - 1 & i == i and a ^ b == 0:
		ans ^= b
print(ans)


def main():
	n = int(input())
	a = list(map(lambda x: int(x) - 1, list(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()


def pascal_parity(N):
	if N & -N == N:
		return [1] * N
	else:
		n = N - (1 << N.bit_length() - 1)
		p = pascal_parity(n)
		return p + [0] * (N - 2 * n) + p
N = int(input())
A = list(map(lambda x: int(x) - 1, input()))
P = pascal_parity(N)
if 1 in A:
	if sum((a * p for (a, p) in zip(A, P))) % 2 == 1:
		print(1)
	else:
		print(0)
else:
	pa = 0
	for (p, a) in zip(P, A):
		if p == 1 and a == 2:
			pa += 1
	if pa % 2 == 1:
		print(2)
	else:
		print(0)


def test(a):
	print(*a)
	for i in range(len(a) - 1):
		a = [abs(a1 - a0) for (a0, a1) in zip(a, a[1:])]
		print(*a)

def solve(n, aaa):
	if '2' not in aaa:
		factor = '3'
		effect = 2
	else:
		factor = '2'
		effect = 1
	try_list = []
	m = n - 1
	while m:
		l = 1 << m.bit_length() - 1
		m ^= l
		try_list.append((l, m))
	ans = 0
	for (i, a) in enumerate(aaa):
		if a == factor:
			for (l, m) in try_list:
				if i >= l:
					i -= l
				if i == 0:
					ans ^= effect
					break
				elif i > m:
					break
	return ans
n = int(input())
aaa = input()
print(solve(n, aaa))


import sys
sys.setrecursionlimit(10 ** 6)
readline = sys.stdin.readline
read = sys.stdin.read
n = int(input())
a = [int(i) for i in input()]
n -= 1
d = [abs(i - j) for (i, j) in zip(a, a[1:])]
p2 = [0]
for i in range(1, n + 2):
	r = p2[-1]
	while i & 1 == 0:
		r += 1
		i >>= 1
	p2.append(r)

def choose(n, k):
	if p2[n] > p2[k] + p2[n - k]:
		return 0
	else:
		return 1
par = sum((choose(n - 1, i) * di for (i, di) in enumerate(d))) % 2
if par == 1:
	print(1)
elif 1 in d:
	print(0)
else:
	d = [di >> 1 for di in d]
	par = sum((choose(n - 1, i) * di for (i, di) in enumerate(d))) % 2
	if par == 0:
		print(0)
	else:
		print(2)


N = int(input())
A = [int(c) - 1 for c in input()]
x = 0
b = 1 if any((a == 1 for a in A)) else 2
for (k, a) in enumerate(A):
	p = int(N - 1 & k == k)
	if p and a ^ b == 0:
		x ^= b
print(x)


N = int(input())
a = list(map(int, list(input())))
a = list(map(lambda x: x - 1, a))
x = 0
for (i, n) in enumerate(a):
	if n % 2 == 0:
		continue
	elif (N - 1 ^ i) & i == 0:
		x += 1
if x % 2 != 0:
	print(1)
elif 1 in a:
	print(0)
else:
	a = [x // 2 for x in a]
	x = 0
	for (i, n) in enumerate(a):
		if n % 2 == 0:
			continue
		elif N - 1 & i == i:
			x += 1
	if x % 2 != 0:
		print(2)
	else:
		print(0)


N = int(input())
a = [int(s) - 1 for s in input()]
twos = {}
twos[0] = 0
for r in range(1, N):
	count = 0
	tmp = r
	while tmp % 2 == 0:
		tmp //= 2
		count += 1
	twos[r] = twos[r - 1] + count
ncr = {}
for r in range(N):
	if twos[N - 1] - twos[N - 1 - r] - twos[r] > 0:
		ncr[r] = 0
	else:
		ncr[r] = 1
oe = 0
for (r, ai) in enumerate(a):
	oe = (oe + ncr[r] * ai) % 2
if oe == 1:
	print(1)
elif 1 in a:
	print(0)
else:
	oe2 = 0
	for (r, ai) in enumerate(a):
		oe2 = (oe2 + ncr[r] * ai // 2) % 2
	if oe2 == 1:
		print(2)
	else:
		print(0)


n = int(input())
a = [int(t) - 1 for t in input()]
f = 1
if 1 not in a:
	a = [x // 2 for x in a]
	f = 2
s = sum([x for (i, x) in enumerate(a) if n - 1 & i == i])
print(s % 2 * f)


N = int(input())
a = list(map(int, list(input())))
a = list(map(lambda x: x - 1, a))
x = 0
num_mod = [0] * N
for i in range(1, N):
	tmp = 0
	t = i
	while t % 2 == 0:
		t //= 2
		tmp += 1
	num_mod[i] = num_mod[i - 1] + tmp
for (i, n) in enumerate(a):
	if n % 2 == 0:
		continue
	elif num_mod[N - 1] == num_mod[i] + num_mod[N - 1 - i]:
		x += 1
if x % 2 != 0:
	print(1)
elif 1 in a:
	print(0)
else:
	a = [x // 2 for x in a]
	x = 0
	for (i, n) in enumerate(a):
		if n % 2 == 0:
			continue
		elif num_mod[N - 1] == num_mod[i] + num_mod[N - 1 - i]:
			x += 1
	if x % 2 != 0:
		print(2)
	else:
		print(0)


import sys
import math
import heapq
mod = 10 ** 9 + 7
inf = float('inf')
from math import sqrt, ceil
from collections import deque, Counter, defaultdict, OrderedDict
input = lambda : sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from decimal import ROUND_HALF_UP, Decimal
from functools import lru_cache
n = int(input())
s = input()
A = [int(i) - 1 for i in s]
RUI2 = [pow(2, i) for i in range(21)]
import bisect as bi

@lru_cache(maxsize=10 ** 10)
def tan(n):
	if n == 0:
		return [1]
	if n == 1:
		return [1, 1]
	if n == 2:
		return [1, 0, 1]
	i = bi.bisect_right(RUI2, n) - 1
	return tan(n - pow(2, i)) + [0] * (pow(2, i + 1) - n - 1) + tan(n - pow(2, i))
if A.count(1) != 0:
	A = [i % 2 != 1 for i in A]
	a = [i & j for (i, j) in zip(A, tan(n - 1))]
	print(1 if sum(a) % 2 == 1 else 0)
else:
	a = [i // 2 & j for (i, j) in zip(A, tan(n - 1))]
	print(2 if sum(a) % 2 == 1 else 0)


def twos_in_factorial(n):
	return n - bin(n).count('1')

def parity_of_nCr(n, i):
	f = twos_in_factorial
	return f(n) - f(n - i) - f(i) > 0
n = int(input())
nums = list(map(lambda x: int(x) - 1, input().strip()))
no_one = False
if 1 not in nums:
	nums = [num // 2 for num in nums]
	no_one = True
is_odd = False
for (i, num) in enumerate(nums):
	if not parity_of_nCr(n - 1, i) and num & 1:
		is_odd ^= 1
if not is_odd:
	print(0)
else:
	print(1 << no_one)


n = int(input())
a = list(map(int, input()))
a = [e - 1 for e in a]

def cnt_div2(x):
	ret = 0
	while x % 2 == 0 and x != 0:
		x //= 2
		ret += 1
	return ret
now = 0
cnt = [0]
for i in range(1, n):
	now += cnt_div2(n - i)
	now -= cnt_div2(i)
	cnt.append(now)
div2 = [e == 0 for e in cnt]

def f(li):
	ret = 0
	for (e1, e2) in zip(li, div2):
		e1 %= 2
		ret ^= e1 * e2
	return ret
if f(a):
	ans = 1
elif 1 in a:
	ans = 0
else:
	a = [e // 2 for e in a]
	if f(a):
		ans = 2
	else:
		ans = 0
print(ans)


N = int(input())
A = [int(a) - 1 for a in input()]
r = 1 if 1 in A else 2

def parity_of_nCk(n, k):
	return n & k == k
ans = 0
for (i, a) in enumerate(A):
	if a & r:
		if parity_of_nCk(N - 1, i):
			ans ^= 1
print(ans * r)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lucas(n, k):
	return n & k == k
N = INT()
A = [a - 1 for a in list(map(int, input()))]

def check(A):
	mod2 = 0
	for (i, a) in enumerate(A):
		if a == 1:
			mod2 += lucas(N - 1, i)
			mod2 %= 2
	return mod2
res = check(A)
if res == 1:
	print(1)
	exit()
if A.count(1):
	print(0)
	exit()
A = [a // 2 for a in A]
res = check(A)
if res == 1:
	print(2)
else:
	print(0)