#include <stdio.h>
int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
int main() {
	int a = ri();
	int b = ri();
	int c = a + b;
	
	if (c >= 15 && b >= 8) puts("1");
	else if (c >= 10 && b >= 3) puts("2");
	else if (c >= 3) puts("3");
	else puts("4");
	
	return 0;
}

#include <bits/stdc++.h>
using namespace std;using ll=long long;
using vl=vector<ll>;using vi=vector<int>;
using vs=vector<string>;using vc=vector<char>;
using vvl=vector<vl>;using pl=pair<ll,ll>;
using vvc=vector<vc>;using vd=vector<double>;
using vpl=vector<pl>;using vb=vector<bool>;
#define rep(i,r) for(ll i=0;i<(r);i++)
#define Rep(i,l,r) for(ll i=(l);i<(r);i++)
#define print(n) cout<<(n)<<endl
#define all(a)  (a).begin(),(a).end()
#define sortp(d) sort(all(d)) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
/*-----------順列生成-----------------
do
{
}while(next_permutation(all(A)));
*/
//'A'65,'a'97
//cout<<fixed<<setprecision(9)<<;
ll gcd(ll a,ll b) {if(b==0)return a;else return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll modpow(ll a,ll n,ll mod) {ll res=1;while(n>0)
{if(n&1)res=res*a%mod;a=a*a%mod;n >>= 1;}return res;}
ll modinv(ll a,ll mod){return modpow(a, mod - 2, mod);}

ll p=0,q=0,r=0;
ll dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
ll dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll inf=1000000000000; //10^12:∞
ll mod=1000000007; //10^9+7:合同式の法
struct edge{ll to,cost;};
const double pi = acos(-1);

int main(){
    ll a,b;cin>>a>>b;
    if(b>=8&&a+b>=15)print(1);
    else if(b>=3&&a+b>=10)print(2);
    else if(a+b>=3)print(3);
    else print(4);
}
