#include <bits/stdc++.h>
int main() {
  int a[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
  int n, m, sum = 0;
  scanf("%d%d", &n, &m);
  a[n] -= fabs(m - 8);
  if (a[n] % 7 != 0) sum++;
  printf("%d\n", sum + a[n] / 7 + 1);
}
