#include<bits/stdc++.h>
using namespace std;
char s[1000008];
int n,i,j,k,a[1000008];
int main() {
    for(scanf("%d%s",&n,s+1),--n; i++<n;
            i&1?0:a[i]=1+a[i>>1],j|=1==(s[i-1]=abs(s[i]-s[i+1])));
    if(j)
        for(i=n; i--; s[i]&=1);
    for(--n,k=s[i=j=0]; i++<n; (j+=a[n+1-i]-a[i])?0:k^=s[i]);
    printf("%d\n",k),exit(0);
}