#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int m, d;
  cin >> m >> d;
  int a[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  if ((a[m] - (8 - d)) % 7)
    cout << 2 + (a[m] - (8 - d)) / 7;
  else
    cout << 1 + (a[m] - (8 - d)) / 7;
}
