#include <bits/stdc++.h>
using namespace std;
int testCase;
int iinf = 1e9 + 1;
long long inf = 1e16 + 1;
void solve() {
  vector<int> month = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  long long m;
  cin >> m;
  long long d;
  cin >> d;
  m--;
  cout << ((d - 1) + month[m] - 1) / 7 + 1;
}
int main() {
  testCase = 1;
  while (testCase--) {
    solve();
  };
}
