#include <iostream>
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;
  }
}

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

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int a, b, sum = 0;
	while(cin >> a >> b){
		sum += a + b;
		if(sum >= 15 and b >= 8)
			cout << "1\n";
		else if(sum >= 10 and b >= 3)
			cout << "2\n";
		else if(sum >= 3)
			cout << "3\n";
		else
			cout << "4\n";
	}
}