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