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