#include <bits/stdc++.h>
using namespace std;

//vector <long long> v[1000001];

//stack <long long> s, s2;
//bbbbaaaa
//queue <long long> s, s2;

long long int  z[1], x[1][3], y[1][2], m, szu, wy[100][100];
char s[10000000];

long long nwd(long long a, long long b)
{
    while(a*b)
    {
        if(a>b)swap(a, b);
        b%=a;
    }
    return(a+b);
}

int main()
{
    long long int chu, d, e, f, i, j, q, t, k, a, n, b, c, w, p, aa, bb, cc, dd, nn, kk;

    t=1;
    //scanf("%lld", &t);
    for(q=1; q<=t; q++)
    {
        scanf("%lld%lld", &n, &a);

        for(i=1; i<n; i++)
        {
            scanf("%lld", &b);
            a=nwd(a, b);
        }
        printf("%lld\n", a);
    }

    return(0);
}

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair

typedef vector<int> vi;
typedef pair<int,int> pi;
#define REP(i,a,b) for (int i = a; i <= b; i++)

void solve(){


int a,b,c;
cin>>a>>b;

if(a == b){cout<<a;return;}

if(a==0){
    if(b == 1){
        cout<<2;return;
    }
    cout<<1;return;
}
else if(a == 1){
    if(b == 2){
        cout<<0;return;
    }
    cout<<2;return;
}
else{
        if(b == 1){
        cout<<0;return;
    }
    cout<<1;return;
}





}


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n =1;
// cin>>n;
while(n--){
    // cout<<n;
    solve();
}
}