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