#include <bits/stdc++.h>
using namespace std;
long long m, d;
long long a[1000][1000];
long long me[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> m >> d;
  long long cnt = 1, cnt1 = 0;
  long long pr = 0;
  long long ok = 0;
  for (long long i = 1; i <= 1000; i++) {
    if (ok == 0) {
      for (long long j = d; j <= 7; j++) {
        a[i][j] = cnt;
        cnt++;
        if (cnt - 1 == me[m - 1]) {
          cout << i;
          return 0;
        }
      }
      ok = 1;
    } else {
      for (long long j = 1; j <= 7; j++) {
        a[i][j] = cnt;
        cnt++;
        if (cnt - 1 == me[m - 1]) {
          cout << i;
          return 0;
        }
      }
    }
  }
}
