#include<bits/stdc++.h>
using namespace std;
#define loop(i,n) for(int i=0;i<n;i++)
#define loop1(i,n) for(int i=1;i<=n;i++)
#define rloop(i,n) for(int i=n-1;i>=0;i--)
#define in cin>>
#define ou cout<<
#define nl cout<<endl;
#define yes cout<<"YES"<<endl;
#define no  cout<<"NO"<<endl;
void solve()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<a<<endl;
    else
    {
        if(a==0)
        {
            if(b==1)
                cout<<2<<endl;
            else
                cout<<1<<endl;
        }
        else if(a==1)
        {
            if(b==0)
                cout<<2<<endl;
            else
                cout<<0<<endl;
        }
        else
        {
            if(b==0)
                cout<<1<<endl;
            else
                cout<<0<<endl;
        }
    }
}
int main()
{
    //int t;
    //in t;
    //while(t--){
    solve();
    //}
    return 0;
}

#include <iostream>
using namespace std;

int main(){ int x,y;
cin>>x>>y;
if(x==y){cout<<x;}
else if(x==0&&y==1){cout<<2;}
else if(x==0&&y==2){cout<<1;}
else if(x==1&&y==0){cout<<2;}
else if(x==1&&y==2){cout<<0;}
else if(x==2&&y==0){cout<<1;}
else if(x==2&&y==1){cout<<0;}
return 0;
}