#include <bits/stdc++.h>
using namespace std;
int f[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
int main() {
  int ans = 1, n, m;
  cin >> n >> m;
  for (int i = 2; i <= f[n]; i++) {
    if (m == 7)
      m = 1, ans++;
    else
      m++;
  }
  cout << ans << endl;
  return 0;
}
