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 static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static boolean isOdd(int n, int k) {
		if (2 * k > n) {
			k = n - k;
		}
		if (k == 0) {
			return true;
		}
		int m = n - Integer.highestOneBit(n);
		return k <= m && isOdd(m, k);
	}

	static void solve() throws Exception {
		int n = scanInt();
		int a[] = new int[n];
		String s = scanString();
		boolean haveOne = false;
		for (int i = 0; i < n; i++) {
			a[i] = s.charAt(i) - '1';
			if (a[i] == 1) {
				haveOne = true;
			}
		}
		if (!haveOne) {
			for (int i = 0; i < n; i++) {
				a[i] >>= 1;
			}
		}
		boolean odd = false;
		for (int i = 0; i < n; i++) {
			if (a[i] == 1 && isOdd(n - 1, i)) {
				odd = !odd;
			}
		}
		out.print(odd ? haveOne ? 1 : 2 : 0);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}