var Queue, cnt, val:longint;
fin:text;
begin
  cnt:=0;
  assign(fin,'input.txt');
  reset(fin);
  while not eof(fin) do
  begin
    readln(fin,val);
    if cnt = 0
    then begin
      Queue:=val;
      cnt:=cnt+1;
    end
    else if val = Queue
         then cnt:=cnt+1
         else cnt:=cnt-1;
  end;
  writeln(Queue);
  close(fin);
end.
