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