//#include <bits/stdc++.h>
#include <cassert>
#include <algorithm>
#include <set>
#include <map>
#include <ctime>
#include <iostream>
//#include <fstream>

#define MAX_N 1000000

using namespace std;



int n;
int a[2][MAX_N + 1];

bool triunghi(int sl, int sc, int len, int l, int c)
{

//if(len != 0)
  //  cout << " SUNT " << sl << " " << sc << " " << len << " " << l << " " << c << "\n";


    if(sl == l && sc == c)
        return 1;

    if(l < sl)
        return 0;

    if(l == sl + len - 1)
    {
        int dr = sc;
        int st = dr - len + 1;

        return (st <= c && c <= dr);
    }

    int x = len >> 1;
    if(l <= sl + x - 1)
        return triunghi(sl, sc, x, l, c);

    int dr = sc;
    int st = dr - len + 1;
    int mid = (st + dr) / 2;


    if(c <= mid)
        return triunghi(sl + x, sc - x, x, l, c);

    else
        return triunghi(sl + x, sc, x, l, c);

    assert(1 == 0);

    return 0;
}
/*

void afis(int x, int nm)
{

   // cout << triunghi(1, 69, 1024, 6, 64);

   // return;

    for(int i = 1; i <= nm; i ++)
    {
     //   int y = triunghi(1, 69, 1024, 1 + n - nm, i);
   //     couti << a[x][i];// + y;


      //  if(a[x][i] != y)
      //  cout << a[x][i] << " " << y << " " << 1 + n - nm << " " << i  << "++\n";

       // assert(a[x][i] == y);
    }
//    couti << "\n";
}*/

const int DEBUG  = 0;
const int MXN = 7000;

int getSpec()
{
    int sum = 0;
    int p2 = 1 << 20;
    int last = 1;

    int ap[3];
    ap[1] = ap[2] = 0;
    int cr = 1, ant = 0;
    for(int i = 2; i <= 100; i ++)
    {
        ap[1] = ap[2] = 0;
        last = i;
        for(int j = 1; j <= n + 1 - last; j ++)
        {
            a[cr][j] = abs(a[ant][j] - a[ant][j + 1]);
            ap[a[cr][j]] ++;
          //  cout << a[cr][j];
        }
        //cout <<"\n";

        swap(cr, ant);

        if(ap[1] == 0 || ap[2] == 0)
            break;
    }

    ap[1] = ap[2] = 0;
    for(int i = 1; i <= n + 1 - last; i ++)
    {
        int y = triunghi(last, i, p2, n, 1);

        if(y == 1)
        {
            //cout << "INTRA " << a[ant][i] << "\n";
            ap[a[ant][i]] ++;
             //sum = abs(sum - a[0][i]);
        }
    }

    int rez = 0;
    for(int i = 1; i <= 2; i ++)
    {
        if(ap[i] & 1)
            rez = i;
    }

    cout << rez << "\n";
}

int solve()
{
    int MX = 200000000;

    int last = 1;
    int ant = 0, cr = 1;

    if(n <= MXN)
    {
        for(int i = 2; i <= min(n, MX / n); i ++)
        {
            last = i;
            for(int j = 1; j <= n + 1 - i; j ++)
                a[cr][j] = abs(a[ant][j] - a[ant][j + 1]);

           // if(DEBUG)
             //   afis(cr, n - i + 1);

            swap(cr, ant);
        }

        if(min(n, MX / n) == n)
            cout << a[ant][1] << "\n";

        return a[ant][1];
    }

    else
    {
        return getSpec();
    }

}

string s;
const int TEST = 10000;
const int XN = 500;

int b[MAX_N + 1];



int main()
{


   // if(DEBUG != 1)
   // {
        cin >> n >> s;
        for(int i = 1; i <= n; i ++)
            a[0][i] = s[i - 1] - '0';

        getSpec();
       // solve();


   // }
/*
    else
    {
        srand(time(0));
        for(int x = 1; x <= TEST; x ++)
        {
            n = XN;
            for(int i = 1; i <= n; i ++)
                b[i] = a[0][i] = (rand() % 3 + 1);

            int r1 = solve();

            for(int i = 1; i <= n; i ++)
                a[0][i] = b[i];
            int r2 = getSpec();

            couti << r1 << " " << r2 << "\n";

            couti.flush();
            cout.flush();
            assert(r1 == r2);

            cout << "\n\n";
        }

    }
    */
    return 0;
}


Measured memory_bytes: 11012