#include <bits/stdc++.h>
namespace patch {
template <typename T>
std::string to_string(const T& n) {
  std::ostringstream stm;
  stm << n;
  return stm.str();
}
}  // namespace patch
using namespace std;
int main() {
  long long int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  long long int N, M, ans;
  while (cin >> N >> M) {
    long long int dy = (((8 - M) % 7));
    ans = days[N] - dy;
    ans = (ans + 6) / 7;
    cout << ans + (dy != 0) << '\n';
  }
  return 0;
}
