#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, d;
  cin >> m >> d;
  int ndays =
      (m == 2 ? 28 : ((m == 4 || m == 6 || m == 9 || m == 11) ? 30 : 31));
  int n = 0, e = d == 7 ? 1 : 8 - d;
  for (int i = 1; i <= ndays; i++) {
    if (i == e) {
      n++;
      if ((e + 7) <= ndays) e += 7;
    }
  }
  if (e < ndays) n++;
  cout << n;
}
