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