function Main(input) {
  input = input.split("\n");
  var N = input[0].split(" ").map(Number);
  var A = input[1].split(" ").map(Number);
if(N[0]+1==A[0]){
  console.log(1);
}else{
  console.log(0);
}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));