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