#include <bits/stdc++.h>
using namespace std;
int arr[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int m, d;
  cin >> m >> d;
  int p = arr[m] - (8 - d);
  if (p % 7 == 0)
    cout << 1 + p / 7;
  else
    cout << 2 + p / 7;
}
