{$apptype console}
{$o-,r+,q+}
uses
  sysutils, math;

const
  problem_name = 'c';

type
  int = longint;

var
  n, i : int;
  ans : int;

function gcd(a, b : int) : int;
begin
  if b = 0 then result := a
  else result := gcd(b, a mod b);
end;

begin
	assign(input, 'c.in');
  reset(input);
  
  assign(output, 'c.out');
  rewrite(output);
  read(n);
  ans := 0;
  for i := 1 to n - 1 do
  begin
    if gcd(n, i) = 1 then
      inc(ans);
  end;

  writeln(ans);
end.
