#include<iostream>
#include<cstdio>
#define Abs(x) ((x)<0?-(x):(x))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=10001000;
int n,fl,ans,a[N];
char s[N];
int main(){
	//freopen("1.in","r",stdin);
	//freopen("1.out","w",stdout);
	scanf("%d%s",&n,s);
	n-=2;
	FOR(i,0,n) a[i]=Abs(s[i+1]-s[i]);//cerr<<a[i];
	fl=2;
	FOR(i,0,n)if(a[i]==1) fl=1;
	FOR(i,0,n)if(a[i]==fl) ans^=(n&i)==i;
	ans*=fl;
	cout<<ans<<'\n';
}