var
  i, j, n: integer;

begin
assign(input, 'metro.in');  reset(input);
assign(output,'metro.out'); rewrite(output);
  readln(n, i, j);
  if (n mod 2 = 0) and (i < j) then         
  if j - i < n div 2  then writeln (j - i - 1)
                      else writeln (N - j + i -1 );
  if (n mod 2 = 0) and (i > j) then 
  if i - j < n div 2  then writeln (i - j - 1)
                      else writeln (N - i + j -1 );
  if (n mod 2 <> 0) and (i < j) then
  if j - i < (n - 1) div 2  then writeln(j - i - 1)
                            else writeln( n - j + i - 1 );
  if (n mod 2 <> 0) and (i > j)then
  if i - j < (n -1) div 2   then writeln(i - j - 1)
                            else writeln( n - i + j - 1 );
close(output);
close(input);

end.


 

