#include <iostream>

using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    switch(x+y){
        case 0: cout << 0 << endl; break;
        case 1: cout << 2 << endl; break;
        case 2: cout << 1 << endl; break;
        case 3: cout << 0 << endl; break;
        case 4: cout << 2 << endl; break;
    }
    return 0; 
}
#include <bits/stdc++.h>
#include <string>
typedef long long int ll;
typedef long double ld;
using namespace std;
ll mod = 1e9 + 7;

int solve()
{
    return 0;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x, y;
    cin >> x >> y;
    if (x == y)
        cout << x << endl;
    else if ((x == 0 && y == 1) || (x == 1 && y == 0))
        cout << 2 << endl;
    else if ((x == 1 && y == 2) || (x == 2 && y == 1))
        cout << 0 << endl;
    else if ((x == 0 && y == 2) || (x == 2 && y == 0))
        cout << 1 << endl;
    return 0;
}