#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 998244353
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------
/*freopen("data.in"  ,"r",stdin);
    freopen("main.out","w",stdout);*/
struct mint{
    using ull=unsigned long long int;
    ull v;
    mint(ll vv=0){s(vv%mod+mod);}
    mint& s(ull vv){
        v=vv<mod?vv:vv-mod;
        return *this;
    }
    //オーバーロード
    mint operator-()const{return mint()-*this;}//符号反転
    mint&operator+=(const mint&val){return s(v+val.v);}
    mint&operator-=(const mint&val){return s(v+mod-val.v);}
    mint&operator*=(const mint&val){
        v=ull(v)*val.v%mod;
        return *this;
    }
    mint&operator/=(const mint&val){return *this*=val.inv();}
    mint operator+(const mint&val){return mint(*this)+=val;}
    mint operator-(const mint&val){return mint(*this)-=val;}
    mint operator*(const mint&val){return mint(*this)*=val;}
    mint operator/(const mint&val){return mint(*this)/=val;}
    mint pow(int n)const{
        mint res(1),x(*this);
        while(n){
            if(n&1)res*=x;
            x*=x;
            n>>=1;
        }
        return res;
    }
    mint inv()const{return pow(mod-2);}
    //拡張ユークリッドの互除法
    /* mint inv()const{
        int x,y;
        int g=extgcd(v,mod,x,y);
        assert(g==1);
        if(x<0)x+=mod;
        return mint(x);
    }*/
    friend ostream& operator<<(ostream&os,const mint&val){
        return os<<val.v;
    }//出力
    bool operator<(const mint&val)const{return v<val.v;}
    bool operator==(const mint&val)const{return v==val.v;}
    bool operator>(const mint&val)const{return v>val.v;}
};
const ll MAX = 2000010;//設定
mint fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void init(){
    fac[0] = fac[1] = 1;
    for(int i=1;i<MAX;i++)fac[i]=fac[i-1]*i;
    finv[MAX-1]=fac[MAX-1].inv();
    for(int i=MAX-2;i>=0;i--)finv[i]=finv[i+1]*(i+1);
    for(int i=MAX-2;i>=1;i--)inv[i]=finv[i]+fac[i-1];
}
//階乗
mint factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return fac[n]*finv[k];
}
// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}
ll modpow(ll a, ll n) {//a^n(MOD)を求める
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;//次の準備
        n >>= 1;
    }
    return res;
}
ll waru(ll a,ll b){
    return a*modpow(b,MOD-2)%MOD;
}

ll permutation(ll n,ll r)
{
    ll a=1;
    for(int i=n-r+1;i<=n;i++)
        a*=i;
    return a;
}
/*int h,w;
char s[100][100];
int ans=0;*/
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    /*cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
        }
    }

    int stx=0,sty=0;
    if(s[0][0]=='#')ans++;
    queue<Pin>q;
    q.push(mp(stx,sty));
    while(!q.empty()){
        Pin now=q.front();q.pop();
        int x=now.fi,y=now.se;
        if(x==h-1&&y==w-1){
            break;
        }
        for(int i=0;i<2;i++){
            if(i==0){
                int nx=x+1;
                int ny=y;
                if(nx<h){
                    if(s[nx][ny]=='.'){
                        q.push(mp(nx,ny));
                    }
                    else{
                        continue;
                    }
                }
            }
            else{
                int nx=x;
                int ny=y+1;
                if(ny<w){
                    if(s[nx][ny]=='.'){
                        q.push(mp(nx,ny));
                    }
                    else{
                        continue;
                    }
                }
            }
        }
    }
    cout<<ans<<Endl;*/

    int n;cin>>n;
    V<int>a(n);
    string s;cin>>s;
    bool abc=0;
    for(int i=0;i<n;i++){
        a[i]=s[i]-'0';
        if(a[i]==2)abc=1;
    }
    V<int>b;
    for(int i=0;i<n-1;i++){
        int tmp=abs(a[i]-a[i+1]);
        if(abc==0){
            if(tmp==2){
                b.pb(1);
            }
            else b.pb(0);
        }
        else{
            if(tmp==2||tmp==0){
                b.pb(0);
            }
            else b.pb(1);
        }
    }

    int ans=0;
    n=b.size();
    for(int i = 0; i < n; i++){
        int j = (n-1) - i;
        if((i ^ j) == (i + j)){
            ans += b[i];
            ans %= 2;
        }
    }

    if(abc==0&&ans==1)ans=2;
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 59032