// @flow

const main = (input /*: string */) => {
  const r = reader(input)
  const [m1, d1] = r.ns()
  // const [m2, d2] = r.ns()
  if (m1 === 2) {
    console.log(Number(d1 === 29))
  } else {
    console.log(Number(d1 === 30) ^ Number(((m1 >> 2) & 1) === 1))
  }
}

// const values = obj => Object.keys(obj).map(e => obj[e]);

const reader = (str /*: string*/) => {
  const lines = str.trim().split('\n')
  const s = () => lines.shift() || ''
  const n = () => Number(s())

  const ss = () => s().split(' ')
  const ns = () => ss().map(v => Number(v))
  return { lines, s, n, ss, ns }
}

const getInput = () => require('fs').readFileSync('/dev/stdin', 'utf8')
main(getInput())
