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

typedef long long ll;
typedef unsigned long long ull;

const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const int MOD = 1e9+7;
const int N = 1e5+7;

void test_cases(){
	int  n,m;
	cin >> n >> m;
	set<int> mp;
	mp.insert(n);
	mp.insert(m);
	if(mp.size()==1){
		cout << m;
	}else{
		if((n==1&&m==2)||(n==2&&m==1))cout << "0";
		else if((n==1&&m==0)||(n==0&&m==1))cout << "2";
		else cout << "1";
	}
}

	
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int t = 1;
	//cin >> t;

	for(int tt = 1; tt <= t; tt++){
		test_cases();
	}

	return 0;
}
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<functional>
#include<numeric>
using namespace std;
 
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
typedef long long ll;
const int MAXN = 2e5+5, INF = 0x3f3f3f3f, MOD = 998244353;
const ll INFL = 0x3f3f3f3f3f3f3f3f;

const int M = 30;
void run(){
    int a,b; cin>>a>>b;
    if(a==b)cout<<a<<'\n';
    else cout<<3-a-b<<'\n';
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int t=1;
    //cin>>t;
    while(t--)run();
    return 0;
}