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