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

int main() {
    int a, b;
    cin >> a >> b;
    
    if(a + b >= 15 && b >= 8) cout << 1 << endl;
    else if(a + b >= 10 && b >= 3) cout << 2 << endl;
    else if(a + b >= 3) cout << 3 << endl;
    else cout << 4 << endl;

    return 0;
}
#include <bits/stdc++.h>
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define vl vector<ll>
#define pii pair<int, int>
#define ull unsigned long long
using namespace std;
typedef tuple<ll, ll, ll> ti;
const ll INF=1e17;
void dijkstra(vector<vector<pair<int, int>>>& adj, int x) {
    int n = adj.size();
    priority_queue<pair<ll, int>> q;
    vector<bool> processed(n+1, false);
    vl dist(n+1, LONG_MAX);
    dist[x] = 0;
    q.push({0, x});
    while (!q.empty()) {
        int a = q.top().second;
        q.pop();
        if (processed[a]) continue;
        processed[a] = true;
        for (auto it: adj[a]) {
            int b = it.first, w = it.second;
            if (dist[b] > dist[a] + w) {
                dist[b] = dist[a] + w;
                q.push({-dist[b], b});
            }
        }
    }
}
bool cmp(pair<int, int>& a, pair<int, int>& b) {
    if (a.first == b.first) return a.second < b.second;
    return a.first > b.first;
}
string decimalToBinary(ll n) 
{ 
    //finding the binary form of the number and  
    //coneverting it to string.  
    string s = bitset<64> (n).to_string(); 
      
    //Finding the first occurance of "1" 
    //to strip off the leading zeroes. 
    const auto loc1 = s.find('1'); 
      
    if(loc1 != string::npos) 
        return s.substr(loc1); 
      
    return "0"; 
}

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