#include <bits/stdc++.h>
int main() {
  int m, n, o;
  while (scanf("%d%d", &m, &n) != EOF) {
    if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
      if ((n + 31 - 1) > 35)
        printf("%d\n", 6);
      else
        printf("%d\n", 5);
    } else if (m == 2) {
      if ((n + 28 - 1) > 28)
        printf("%d\n", 5);
      else
        printf("%d\n", 4);
    } else {
      if ((n + 30 - 1) > 35)
        printf("%d\n", 6);
      else
        printf("%d\n", 5);
    }
  }
}
