#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int a, b;
  cin >> a >> b;
  int c = a + b;
  if (c >= 15 && b >= 8) {
    cout << 1;
  } else if (c >= 10 && b >= 3) {
    cout << 2;
  } else if (c >= 3) {
    cout << 3;
  } else {
    cout << 4;
  }
  cout << "\n";
  return 0;
}

/*
 * Author: Moon_light
 * Solution: 
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define lowbit(x) ((x)&(-x))
#define sz(x) ((int)x.size())
#define fr(x) freopen(x,'r',stdin)
#define fw(x) freopen(x,'w',stdout)
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) begin(a),end(a)
#define bitcnt(x) (__builtin_popcountll(x))
#define rep(i,a,b) for(int i = (a);i<=(b); ++i)
#define per(i,a,b) for(int i = (a);i>=(b); --i)
typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VB;
typedef double db;

//global variable
const int N = 1;
const int mod = 1e9+7;
int t;


//functions
LL qmi(LL a,LL k,LL mod){
    LL res = 1;
    while(k){
        if(k&1) res = res*a%mod;
        k >>= 1;
        a = a*a%mod;
    }
    return res%mod;
}
int gcd(int a,int b) {
    return b==0? a:gcd(b,a%b);
}

//code from here! Come on! Have a pleasant experience~
int main()
{
    IO;
    int a,b;
    cin>>a>>b;
    int c = a+b;
    int ans = 4;
    if(c >= 15 && b >= 8){
        ans = 1;
    }else if(c >= 10 && b >= 3){
        ans = 2;
    }else if(c >= 3){
        ans = 3;
    }
    cout<<ans<<endl;
    return 0;
}