#include <bits/stdc++.h>
int main() {
  int m, d, t[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  scanf("%d%d", &m, &d);
  d = (d - 1) + (t[m - 1] % 7);
  if (d == 0) {
    printf("4\n");
  } else if (d <= 7) {
    printf("5\n");
  } else {
    printf("6\n");
  }
  return 0;
}
