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