#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int m, d;
  cin >> m >> d;
  int mnth[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int wk = 1;
  for (int i = 0; i != mnth[m - 1]; i++) {
    if (d == 8) {
      wk++;
      d = 1;
    }
    d++;
  }
  cout << wk << "\n";
  return 0;
}
