#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, p;
  scanf("%d %d", &a, &b);
  int ct = 0, i;
  if (a == 2)
    p = 28;
  else if (a == 1 || a == 3 || a == 5 || a == 7 || a == 8 || a == 10 || a == 12)
    p = 31;
  else
    p = 30;
  for (i = (7 - b) + 2; i <= p; i = i + 7) {
    ct = ct + 1;
  }
  printf("%d\n", ct + 1);
  return 0;
}
