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