{-------------------------------

 -------------------------------
  # Max Tkachenko # Group 112 #
 -------------------------------
}

Program task_3_29___V(input,output);

 var
  a, d1, d2, d3, d4 : integer;
  res : boolean;

 begin
  writeln('Input A (4 digit):');
   readln(a);

   d1 := a mod 10;
   d2 := a mod 100 div 10;
   d3 := a mod 1000 div 100;
   d4 := a mod 10000 div 1000;

    res := (d1 = d3)and(d2 = d4) or (d1=d4)and(d2=d3);

   writeln(res);
  readln;
 end.