#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, ans;
  cin >> n >> m;
  if (n <= 7 && n % 2 != 0 && (m == 7 || m == 6))
    ans = 6;
  else if (n == 2 && m == 1)
    ans = 4;
  else if (n <= 7 && n != 2 && n % 2 == 0 && (m == 7))
    ans = 6;
  else if (n > 7 && n % 2 != 0 && (m == 7))
    ans = 6;
  else if (n > 7 && n % 2 == 0 && (m == 7 || m == 6))
    ans = 6;
  else
    ans = 5;
  cout << ans << endl;
}
