#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, d, date = 1, days_in_month, result = 0;
  cin >> m >> d;
  days_in_month =
      (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12)
          ? 31
          : 30;
  if (m == 2) days_in_month = 28;
  while (date <= days_in_month) {
    date += (result == 0) ? (7 - d + 1) : 7;
    result++;
  }
  cout << result;
}
