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