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