#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define setval(arr,v) memset(arr,v,sizeof(arr));
#define int long long int
#define mod 1000000007
#define v vector
#define umap unordered_map
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define fi first
#define se second
#define INF 1000000000000000
using namespace std;

void solve()
{
	int x,y;
	cin>>x>>y;
	if(x == y)
		cout<<x;
	else
	{
		for (int i = 0; i < 3; ++i)
		{
			if(x != i && y != i)
				cout<<i;
		}
	}


}
 
 
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	// cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
 
}
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const int inf = 1 << 30;
const ll infll = 1LL << 60;
const int mod = 1000000007;
const int mod9 = 998244353;

int main(){
    int x, y;
    cin >> x >> y;

    if((x + y)%3 == 0){
        cout << 0 << endl;
    }
    else if((x + y)%3 == 1){
        cout << 2 << endl;
    }
    else{
        cout << 1 << endl;
    }
}
