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