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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cerr << #a << " = " << a << endl

const double PI = acos(-1);
const int inf = 1001001001;
const int mod = (int)1e9+7;
//const ll inf = 1e15;
//const ll mod = 1e9+7;

int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};

int main() {
    int a, b;
    cin >> a >> b;

    int ans = 4;
    if (a+b >= 15 && b >= 8) ans = 1;
    else if (a+b >= 10 && b >= 3) ans = 2;
    else if (a+b >= 3) ans = 3;
    cout << ans << endl;
}
#include<iostream>
using namespace std;
int A, B;

int main(void){
  cin >> A >> B;
  if( A + B >= 15 ){
    if( B >= 8 ){
      cout << 1 << endl;
    }
    else if( B >= 3 ){
      cout << 2 << endl;
    }
    else{
      cout << 3 << endl;
    }
  }
  else if( A + B >= 10){
    if( B >= 3 ){
      cout << 2 << endl;
    }
    else{
      cout << 3 << endl;
    }
  }
  else if( A + B >= 3){
    cout << 3 << endl;
  }
  else{
    cout << 4 << endl;
  }
  return(0);
}