function main(input) {
  let args = input.split(' ');
  let a = parseInt(args[0], 10);
  let b = parseInt(args[1], 10);

  let count = 0;
  let d = new Date('2018/1/1');
  while (true) {
    let date = d.getDate();
    let month = d.getMonth() + 1;
    if (date === month) {
      count += 1;
    }
    d = new Date(d.getTime() + 60 * 60 * 24 * 1000);

    if (d.getFullYear() > 2018 || (month === a && date == b)) {
      break;
    }
  }
  console.log(count);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
