#include <bits/stdc++.h>
using namespace std;
int k = 1, i, j, m, d,
    ay[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  cin >> m >> d;
  i = d;
  j = 1;
  while (1) {
    k++;
    if (k > ay[m]) break;
    i++;
    if (i > 7) {
      i = 1;
      j++;
    }
  }
  cout << j;
}
