#include <bits/stdc++.h>
using namespace std;
int month(int x) {
  if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
    return 31;
  else if (x == 2)
    return 28;
  else
    return 30;
}
int main() {
  int m, d, temp = 1;
  cin >> m >> d;
  m = month(m);
  for (int i = 1; i < m; i++) {
    d += 1;
    if (d == 8) {
      temp += 1;
      d = 1;
    }
  }
  cout << temp << "\n";
}
