#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int x;
  cin >> x;
  return x;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &vec) {
  for (int i = 0; i < vec.size(); ++i) in >> vec[i];
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); ++i) out << vec[i] << " ";
  return out;
}
int main() {
  int n = in(), m = in();
  int z;
  if (n == 2)
    z = 28;
  else if (n == 4 || n == 6 || n == 9 || n == 11)
    z = 30;
  else
    z = 31;
  z = z + m - 7 - 1;
  int f = z / 7 + (z % 7 > 0);
  cout << f + 1;
  return 0;
}
