#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, a, b, c, cnt = 0, cnt1 = 0, count = 0, d;
  cin >> m >> d;
  if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
    if (d == 6 || d == 7)
      cout << 6 << endl;
    else
      cout << 5 << endl;
  } else if (m == 4 || m == 6 || m == 9 || m == 11) {
    if (d == 7)
      cout << 6 << endl;
    else
      cout << 5 << endl;
  } else {
    if (m == 2 && d == 1)
      cout << 4 << endl;
    else
      cout << 5 << endl;
  }
  return 0;
}
