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

int main() {
	int A,B;
	cin>>A>>B;
	int solids=A+B;
	if(solids >= 15 and B>=8) cout<<1<<endl;
	else if(solids >= 10 and B>=3) cout<<2<<endl;
	else if(solids >= 3) cout<<3<<endl;
	else cout<<4<<endl;
	
	return 0;
}
#include <bits/stdc++.h>
using namespace std;

//.define
// #define FILE_IN_OUT
#define RET(_x)    cout << (_x) << '\n'; return;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
inline P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll = int64_t;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<int>(1e9 + 7);

//.data

//.code
void SolveTask() {
    int a, b;
    cin >> a >> b;
    if (a + b >= 15 && b >= 8) {
        RET(1);
    }
    if (a + b >= 10 && b >= 3) {
        RET(2);
    }
    if (a + b >= 3) {
        RET(3);
    }
    cout << 4 << endl;
}

int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int test_cases = 1;
    // cin >> test_cases;
    for (int yt = 1; yt <= test_cases; ++yt) {
        SolveTask();
    }
#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}