#include <bits/stdc++.h>
using namespace std;
const int M = 100000;
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int main() {
  int m, d;
  cin >> m >> d;
  if (m == 2) {
    if (d == 1)
      cout << 4 << "\n";
    else
      cout << 5 << "\n";
  } else if ((m <= 7 && m % 2 == 1) || (m > 7 && m % 2 == 0)) {
    if (d == 6 || d == 7)
      cout << 6 << "\n";
    else
      cout << 5 << "\n";
  } else {
    if (d == 7)
      cout << 6 << "\n";
    else
      cout << 5 << "\n";
  }
  return 0;
}
