#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using pi = pair<long long, long long>;
using vpi = vector<pi>;
template <typename A, typename B>
inline void chmin(A &a, B b) {
  if (a > b) a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b) {
  if (a < b) a = b;
}
void solve() {
  vi months = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  long long m, d;
  cin >> m >> d;
  long long days = months[m - 1] + (7 + d - 1) % 7;
  long long weeks = days / 7;
  if (days % 7) weeks++;
  cout << weeks << "\n";
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
