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