#include <bits/stdc++.h>
using namespace std;
int main() {
  int month[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int m, d;
  while (cin >> m >> d) {
    if ((d == 7 && month[m] == 31) || (d == 6 && month[m] == 31) ||
        (d == 7 && month[m] == 30)) {
      cout << month[m] / 7 + 2 << endl;
    } else if ((month[m] == 28 && d == 1))
      cout << "4" << endl;
    else
      cout << month[m] / 7 + 1 << endl;
  }
  return 0;
}
