#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, l;
  cin >> n >> m;
  if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12) {
    if (m <= 5)
      cout << "5";
    else
      cout << "6";
  } else if (n == 4 || n == 6 || n == 9 || n == 11) {
    if (m <= 6)
      cout << "5";
    else
      cout << "6";
  } else {
    if (m == 1)
      cout << "4";
    else
      cout << "5";
  }
}
