#include <bits/stdc++.h>
using namespace std;
void pause() {}
int dv(int a, int b) {
  double s;
  s = (a - (a % b)) / b;
  int d;
  d = (int)(s + 0.5);
  return d;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int k, i;
  k = 1;
  if (m == 1) k = 0;
  for (i = 1; i <= 31; i++) {
    if (m == 1) k++;
    m++;
    if (m == 8) m = 1;
    if (n == 4 || n == 6 || n == 9 || n == 11) {
      if (i == 30) break;
    }
    if (n == 2 && i == 28) break;
  }
  cout << k;
  pause();
  return (0);
}
