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


import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		String s = sc.next();
		
		int[] a = new int[n];
		boolean d1 = false;
		int[] d = new int[n-1];
		for(int i = 0; i < s.length(); i++)
		{
			a[i] = s.charAt(i)-'0';
			if(i>0)
			{
				d[i-1] = a[i]-a[i-1];
				if(d[i-1]<0)d[i-1]*=-1;
				if(d[i-1] == 1)d1 = true;
			}
		}
		
		
		int[] mod = new int[n]; //i! mod 2
		
		//n-1 difs
		int m = n-1;
		
		int t1 = 0;
		int t2 = 0;
		
//		System.out.println("Difs: " + m + ", from 0 to " + (m-1));
		for(int take = 0; take <= m-1; take++)
		{ //(m-1) C take 0
			int nn = m-1;
			boolean odd = ((nn) & ((nn)-take)) <= 0;
				
			if ((take & (nn-take)) > 0)
				odd = false;
			else
				odd = true;
			
			if(d[take] == 1 && odd)t1++;
			if(d[take] == 2 && odd)t2++;
			
//			System.out.println( (m-1) + "C" + take + " Dif " + take + ": " + odd);
//			System.out.println("d is " + d[take]);
//			System.out.println( (((m-1) & ((m-1)-take))));
		}
		
		t1 = t1%2;
		t2 = t2%2;
		if(t1<0)t1+=2;if(t2<0)t2+=2;
		
//		System.out.println("t: " + t1 + " " + t2);
		if(t1 == 0 && t2 == 0)
			System.out.println(0);
		else if(t2 == 1 && t1 == 0)
		{
			if(!d1)
				System.out.println(2);
			else
				System.out.println(0);
		}
		else
			System.out.println(1);
		
	}

}
