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