#include <bits/stdc++.h>
using namespace std;
int monthDays[] = {5, 1, 5, 6, 5, 6, 5, 5, 6, 5, 6, 5};
int main() {
  int mth, st1;
  ios_base::sync_with_stdio();
  cin.tie(0);
  cin >> mth >> st1;
  cout << (mth != 2                      ? (st1 <= monthDays[mth - 1] ? 5 : 6)
           : (st1 <= monthDays[mth - 1]) ? 4
                                         : 5)
       << '\n';
  return 0;
}
