#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int q = 30;
  if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12) q++;
  if (n == 2) q = 28;
  q = q - 8 + m;
  if (q % 7 == 0)
    cout << (q / 7) + 1;
  else
    cout << (q / 7) + 2;
}
