#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, d;
  double a, b, c, x, y, z, w;
  cin >> m >> d;
  x = double(m);
  y = double(d);
  a = (7 - y) + 1;
  if (m == 1 || m == 3 || m == 5 || m == 7 || m == 8 || m == 10 || m == 12) {
    b = 31 - a;
    c = b / 7;
    d = ceil(c);
    cout << d + 1;
    return 0;
  } else if (m == 2) {
    b = 28 - a;
    c = b / 7;
    d = ceil(c);
    cout << d + 1;
    return 0;
  } else {
    b = 30 - a;
    c = b / 7;
    d = ceil(c);
    cout << d + 1;
    return 0;
  }
  return 0;
}
