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