function Main(inputs) {
  const input = inputs.split("\n");
  const m1 = Number(input[0].split(" ")[0]);
  const m2 = Number(input[1].split(" ")[0]);

  if(m1 + 1 === m2){
    console.log(1);
  }else{
    console.log(0);
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
