#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int C(int M, int N){
    for(; N; N >>= 1, M >>= 1) if((N & 1) > (M & 1)) return 0;
    return 1;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int N, ans = 0, k = 1;
    cin >> N;
    string s;
    cin >> s;
    for(int i = 1; i < N; i += 1) s[i - 1] = abs(s[i] - s[i - 1]);
    s.pop_back();
    k += not count(s.begin(), s.end(), 1);
    for(int i = 0; i < N - 1; i += 1) ans += C(N - 2, i) * s[i] / k;
    cout << ans % 2 * k;
    return 0;
}
