#include<iostream>
using namespace std;
int main()
{
     int x,y;
    cin >> x >> y;
   if(x==y)
    {
        if(x==0 && y==0)
    {
    cout << "0";
    }
      if(x==1 && y==1)
    {
    cout << "1";
    }
     if(x==2 && y==2)
    {
    cout << "2";
    }  
  } 
    else
    {
    if((x==1 && y==2) || (x==2 && y==1))
    {
    cout << "0";
    }
      if((x==0 && y==2) || (x==2 && y==0))
    {
    cout << "1";
    }
     if((x==0 && y==1) || (x==1 && y==0) )
    {
    cout << "2";
    }
}     return 0;

}
#include<bits/stdc++.h>
#define w(x)            int x; cin>>x; for(int tc=1;tc<=x;tc++)
#define trace(x) 		cerr<<#x<<": "<<x<<" "<<endl;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define pb push_back
#define pqg priority_queue<int>
#define pqs priority_queue<int,vector<int>,greater<int>>
#define mpii map<int,int>
#define endl "\n"
#define YES cout<<"YES\n";
#define Yes cout<<"Yes\n";
#define NO cout<<"NO\n";
#define No cout<<"No\n";
#define mod 1000000007
#define inp(x) cin>>x;


using namespace std;
void solve(int tc) {
	int a, b;
	cin >> a >> b;
	int c = b;
	a += b;
	b = c;
	if (a >= 15 and b >= 8) {
		cout << 1 << endl;
	} else if (a >= 10 and b >= 3) {
		cout << 2 << endl;
	} else if (a >= 3) {
		cout << 3 << endl;
	} else
		cout << 4 << endl;



}

int32_t main() {
	FIO
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	// w(x){
	solve(1);
	// }
	return 0;
}