#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if (a == 2) {
    if (b == 1)
      cout << 4 << endl;
    else
      cout << 5 << endl;
  } else if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 ||
             a == 12) {
    if (b <= 5)
      cout << 5 << endl;
    else
      cout << 6 << endl;
  } else {
    if (b <= 6)
      cout << 5 << endl;
    else
      cout << 6 << endl;
  }
  return 0;
}
