#include <bits/stdc++.h>
using namespace std;
int m[15] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int n, d;
  while (~scanf("%d%d", &n, &d)) {
    int ans = 0;
    if (d == 1) {
      if (m[n] % 7 == 0)
        ans = m[n] / 7;
      else
        ans = m[n] / 7 + 1;
    } else {
      int temp = 7 - d + 1;
      m[n] -= temp;
      int x = m[n] / 7;
      if (m[n] % 7 == 0)
        ans = 1 + m[n] / 7;
      else
        ans = 2 + m[n] / 7;
    }
    cout << ans << endl;
  }
  return 0;
}
