#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, d, x;
  cin >> m >> d;
  if (m == 2 && d == 1) {
    cout << 4;
    return 0;
  }
  if (m == 2) {
    cout << 5;
    return 0;
  }
  if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
    if (d == 7 || d == 6) {
      cout << 6;
      return 0;
    }
  } else {
    if (d == 7) {
      cout << 6;
      return 0;
    }
  }
  cout << 5;
}
