#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e5 + 5;
const long long int INF = 1e18;
const long long int mod = 1e9 + 7;
int main() {
  long long int n, m;
  cin >> n >> m;
  if (n == 2) {
    long long int cur = (7 - m + 1) % 7;
    long long int rem = 28 - cur;
    long long int col = rem / 7;
    long long int colrem = rem % 7;
    if (cur) {
      cur = 1;
    }
    if (colrem == 0) {
      cout << cur + col << endl;
    } else {
      cout << 1 + cur + col << endl;
    }
  } else if (n <= 7) {
    if (n % 2) {
      long long int cur = (7 - m + 1) % 7;
      long long int rem = 31 - cur;
      long long int col = rem / 7;
      long long int colrem = rem % 7;
      if (cur) {
        cur = 1;
      }
      if (colrem == 0) {
        cout << cur + col << endl;
      } else {
        cout << 1 + cur + col << endl;
      }
    } else {
      long long int cur = (7 - m + 1) % 7;
      long long int rem = 30 - cur;
      long long int col = rem / 7;
      long long int colrem = rem % 7;
      if (cur) {
        cur = 1;
      }
      if (colrem == 0) {
        cout << cur + col << endl;
      } else {
        cout << 1 + cur + col << endl;
      }
    }
  } else if (n > 7) {
    if (n % 2) {
      long long int cur = (7 - m + 1) % 7;
      long long int rem = 30 - cur;
      long long int col = rem / 7;
      long long int colrem = rem % 7;
      if (cur) {
        cur = 1;
      }
      if (colrem == 0) {
        cout << cur + col << endl;
      } else {
        cout << 1 + cur + col << endl;
      }
    } else {
      long long int cur = (7 - m + 1) % 7;
      long long int rem = 31 - cur;
      long long int col = rem / 7;
      long long int colrem = rem % 7;
      if (cur) {
        cur = 1;
      }
      if (colrem == 0) {
        cout << cur + col << endl;
      } else {
        cout << 1 + cur + col << endl;
      }
    }
  }
}
