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