/**
 *    author:  Pocket7878
 **/
#include <algorithm>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

/* Consts */
const int INF = 1000000000;
const long long LINF = 1e18;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const long double LEPS = 1.0E-14;

/* Types */
typedef long long ll;
typedef unsigned long long ull;

/* Macros */
#define RNG(i, a, b) for (int i = int(a); i < int(b); ++i)
#define REP(i, b) RNG(i, 0, b)
#define GNR(i, a, b) for (int i = int(b) - 1; i >= int(a); --i)
#define PER(i, b) GNR(i, 0, b)

bool start_with(const std::string& s, const std::string& prefix, int offset) {
  if (s.size() < prefix.size()) return false;
  return std::equal(std::begin(prefix), std::end(prefix),
                    std::begin(s) + offset);
}

// #include <algorithm> // std::equal
// #include <iterator>  // std::rbegin, std::rend
// ends_with("abc", "bc") == true
bool ends_with(const std::string& s, const std::string& suffix) {
  if (s.size() < suffix.size()) return false;
  return std::equal(std::rbegin(suffix), std::rend(suffix), std::rbegin(s));
}

template <class T>
double deg2rad(T& deg) {
  return deg * (M_PI / 180.0);
}

// Debugs
#ifndef ONLINE_JUDGE
#define _LIBCPP_DEBUG 1
#endif

#ifdef ONLINE_JUDGE
#define debug(var) 42
#endif

#ifndef ONLINE_JUDGE
#define debug(var)              \
  do {                          \
    std::cout << #var << " : "; \
    view(var);                  \
  } while (0)
#endif

template <typename T>
void view(T e) {
  std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v) {
  for (const auto& e : v) {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv) {
  for (const auto& v : vv) {
    view(v);
  }
}

void comb(vector<vector<long long int>>& v) {
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}

ll mod_fact(unordered_map<ll, ll>& memo, ll i) {
  if (memo.find(i) != memo.end()) {
    return memo[i];
  } else if (i == 1) {
    return memo[i] = 1;
  } else {
    return memo[i] = (i % MOD) * (mod_fact(memo, i - 1) % MOD) % MOD;
  }
}

vector<long long> enum_divisors(long long N) {
  vector<long long> res;
  for (long long i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      res.push_back(i);
      // 重複しないならば i の相方である N/i も push
      if (N / i != i) res.push_back(N / i);
    }
  }
  // 小さい順に並び替える
  sort(res.begin(), res.end());
  return res;
}

struct Edge {
  ll to;
  ll ki;
  ll ti;

  Edge(ll to, ll ki, ll ti) : to(to), ki(ki), ti(ti) {}
};

using Graph = vector<vector<Edge>>;

std::vector<ll> Eratosthenes( const ll N )
{
    std::vector<bool> is_prime( N + 1 );
    for( ll i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    std::vector<ll> P;
    for( ll i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( ll j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);

  ll A, B;
  cin >> A >> B;

  ll C = A + B;
  if (C >= 15 && B >= 8) {
    cout << 1 << endl;
  } else if (C >= 10 && B >= 3) {
    cout << 2 << endl;
  } else if (C >= 3) {
    cout << 3 << endl;
  } else {
    cout << 4 << endl;
  }
}
#include <iostream>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> pii;
typedef pair<ll,ll> pll;
 
 
/*bool compare_function(const pair<int, int> a, const pair<int, int> b)
{
    return a.first < b.first;
}*/
// use case
//sort(V.begin(), V.end(), compare_function);
 
/*struct compare
{
    bool operator ()(const pair<int, int> &a, const pair<int, int> &b) {
    if (a.second-a.first==b.second-b.first)
    {
        return a.first>b.first;
    }
    return a.second-a.first < b.second-b.first;}
};
priority_queue <pair<int,int>, vector <pair<int,int>>, compare> Q;*/
 
/*void print1(vector <int> X)
{
    for (int i=0; i<X.size(); i++)
    {
        cout<<X[i]<<" ";
    }
    cout<<endl;
    return;
}
 
void print2(vector <vector <int>> X)
{
    for (int i=0; i<X.size(); i++)
    {
    for (int j=0;j<X[i].size();j++) {
        cout<<X[i][j]<<" ";}
    cout<<endl;}
    return;
}*/

int solve(int a, int b) {
	if (a+b>=15 && b>=8) {return 1;}
	if (a+b>=10 && b>=3) {return 2;}
	if (a+b>=3) {return 3;}
	return 4;
	}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    int x=solve(a,b);
    cout<<x<<endl;
    return 0;
}
