#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, l;
  while (cin >> a >> b) {
    if (b == 7) {
      l = 6;
    }
    if (b == 6) {
      l = 5;
    }
    if (b == 5) {
      l = 4;
    }
    if (b == 4) {
      l = 3;
    }
    if (b == 3) {
      l = 2;
    }
    if (b == 2) {
      l = 1;
    }
    if (b == 1) {
      l = 0;
    }
    if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12) {
      int k = 31 + l;
      if (k > 35) {
        cout << "6" << endl;
      } else {
        cout << "5" << endl;
      }
    } else if (a == 2) {
      int k = l + 28;
      if (k > 28) {
        cout << "5" << endl;
      } else {
        cout << "4" << endl;
      }
    } else {
      int k = 30 + l;
      if (k > 35) {
        cout << "6" << endl;
      } else {
        cout << "5" << endl;
      }
    }
  }
  return 0;
}
