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