#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve() {
  int m, d;
  cin >> m >> d;
  vector<int> days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int ans = 0;
  int cur = 0;
  while (cur < days[m]) {
    ans++;
    cur += (7 - d + 1);
    d = 1;
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
