#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  long long int days;
  if (n == 2)
    days = 28;
  else if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12)
    days = 31;
  else
    days = 30;
  long long int sum = 1, ans = 0;
  while (sum <= days) {
    sum += 7;
    ans++;
  }
  if (sum == days) {
    ans = ans;
  } else {
    sum = sum - 7;
    long long int rem = days - sum;
    if (rem <= 7 - m)
      ans = ans;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
