#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,n) for (int i = a; i < n; i++)
#define fr(i,a,n) for (int i = n; i >=a; i--)
#define mod9 1000000009
#define mod7 1000000007
#define INF 1e18
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define ff first
#define ss second
#define pii pair<int, int>
#define mii map<int, int>
#define mkp make_pair
#define pb push_back
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)


signed main()
{
int x,y;
cin>>x>>y;
int c0=0,c1=0,c2=0;
if(x==0 || y==0)
c0++;
 if(x==1 || y==1)
c1++;
 if(x==2 || y==2)
c2++;

//cout<<c0<<" "<<c1<<" "<<c2<<endl;
if(x==y)
cout<<x<<endl;
else
{
    if(c0==0)
    cout<<"0"<<endl;
    else if(c1==0)
    cout<<"1"<<endl;
    else if(c2==0)
    cout<<"2"<<endl;

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

int main(){
    int x, y;
    cin >> x >> y;
    cout << (x==y ? x : 3-x-y) << endl;
}
