#include <bits/stdc++.h>
using namespace std;
int main() {
  int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int m, d;
  cin >> m >> d;
  int num = 2 + (months[m] - (8 - d)) / 7;
  if ((months[m] - (8 - d)) % 7 == 0) num--;
  cout << num;
  return 0;
}
