#include <bits/stdc++.h>
using namespace std;
int main() {
  int month, day;
  cin >> month >> day;
  if (month != 2 && month != 4 && month != 6 && month != 9 && month != 11)
    month = 31;
  else if (month == 2)
    month = 28;
  else
    month = 30;
  month -= (8 - day);
  cout << month / 7 + (month % 7 > 0) + 1;
}
