#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  if ((n == 1 || n == 3 || n == 5 || n == 7 || n == 10 || n == 12 || n == 8) &&
      m <= 5) {
    cout << "5";
  } else if ((n == 1 || n == 3 || n == 5 || n == 7 || n == 10 || n == 12 ||
              n == 8) &&
             m > 5) {
    cout << "6";
  } else if ((n == 4 || n == 6 || n == 9 || n == 11) && m <= 6) {
    cout << "5";
  } else if ((n == 4 || n == 6 || n == 9 || n == 11) && m > 6) {
    cout << "6";
  } else if (n == 2 && m == 1)
    cout << "4";
  else {
    cout << "5";
  }
  return 0;
}
