#include <bits/stdc++.h>
int mon[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int m, d;
  scanf("%d%d", &m, &d);
  int now = 7 - d + 1;
  int res = mon[m] - now;
  int cnt = res / 7;
  int s = res % 7;
  if (s) cnt++;
  cnt++;
  printf("%d\n", cnt);
  return 0;
}
