#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define vi vector<int>
#define ii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define fast_io ios::sync_with_stdio(0);cin.tie(NULL);std::cout.tie(NULL);
# define PI           3.14159265358979323846
#define        trace1(x)                cout<<#x<<": "<<x<<endl
#define        trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define        trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define        trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define        trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define        trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
int mod = 1000000007;
int gcd(int a, int b) {return b ? gcd(b, a % b) : a;}
int lcm(int a, int b) {return a * b / gcd(a, b); }
int bpow(int a,int b) 
{
  int res = 1;
  while (b > 0) {
    if (b & 1)res = ((res) * (a));
      a = ((a) * (a));
      b >>= 1;
  }
  return res;
}
 
void go()
{
#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
}
 
 
signed main() 
  {  
      fast_io
       go();
      int a,b;cin>>a>>b;
      if(a==b){
        cout << a;
        return 0;
      }
      map<int,int> mp;
      mp[0]++;
      mp[1]++;
      mp[2]++;
      mp[a]--;
      mp[b]--;
      if(mp[0]==0)
        mp.erase(0);
      if(mp[1]==0)
        mp.erase(1);
      if(mp[2]==0)
        mp.erase(2);
      
      auto it=*mp.begin();
      cout << it.first << "\n";


} 
 
 
 
 














 
 
 
 

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

#define endl "\n"
#define int long long
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define trace(x) cerr<<#x<<" : "<<x<<endl;

void solve()
{
    int a, b;
    cin >> a >> b;

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

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    for(int i=0;i<t;i++) solve();
    return 0;
}