#include <bits/stdc++.h>
using namespace std;
int a;
int b;
int dni[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  cin >> a >> b;
  if (dni[a - 1] == 31) {
    if (b <= 5) {
      cout << "5";
    } else {
      cout << "6";
    }
  } else {
    if (dni[a - 1] == 28) {
      if (b == 1) {
        cout << "4";
      } else {
        cout << "5";
      }
    } else {
      if (b <= 6) {
        cout << "5";
      } else {
        cout << "6";
      }
    }
  }
  return 0;
}
