Problem: 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

Solution (in PYTHON3):

Solution:
n = int(input())
string = input()
a = []
a_01 = []
a_02 = []
bit_1 = 0
for i in range(n):
    a.append(int(string[i])-1)
    a_01.append((int(string[i])-1)%2)
    a_02.append((int(string[i])-1)//2)
    if int(string[i])-1 == 1: bit_1 = 1

### n-1Ciの偶奇を求めるパート
num_lst = [0 for i in range(n)]
for i in range(1, n):
    p = i
    cnt = 0
    while p % 2 == 0:
        p = p / 2
        cnt += 1
    num_lst[i] = cnt
n_1Ci = [0 for i in range(n)]
for i in range(1, n):
    n_1Ci[i] = n_1Ci[i-1] + num_lst[n-i] - num_lst[i]
### n-1Ciの偶奇を求めるパートここまで

# まずは答えが1かどうか判定
cnt_01 = [0, 0]
for i in range(n):
    cnt_01[a_01[i]] += 1 if n_1Ci[i] == 0 else 0
if cnt_01[1] % 2 == 1:
    print(1)
    exit()

# 答えが1でない時、配列に1が含まれるなら答えは0
if bit_1 == 1:
    print(0)
    exit()

# 配列が0と2で構成されている時
cnt_02 = [0, 0]
for i in range(n):
    cnt_02[a_02[i]] += 1 if n_1Ci[i] == 0 else 0
if cnt_02[1] % 2 == 1:
    print(2)
else:
    print(0)