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