{$r+,q+,o-}
{$apptype console}
type
  int = longint;

var
  n, m, ans, i: int;

label
  next;

begin
	assign(input, 'c.in');
  reset(input);
  
  assign(output, 'c.out');
  rewrite(output);

  read(n); assert((1 <= n) and (n <= 100000));
  ans:=n;

  if (n = 1) then
    ans:=0;

  if (n mod 2 = 0) then
  begin
    ans:=ans div 2;
    while (n and 1 = 0) do
      n:=n shr 1;
  end;

  i:=2;
  while true do
  begin
    m:=trunc(sqrt(n)) + 1;
    if (n = 1) then
      break;

    while (i <= m) do
    begin
      if (n mod i = 0) then
      begin
        n:=n div i;
        while (n mod i = 0) do
          n:=n div i;

        ans:=(i - 1) * (ans div i);
        goto next;
      end;
      inc(i);
    end;
    if (i <= n) then
    begin
      ans:=(n - 1) * (ans div n);
      n:=1;
    end;
next:
  end;

  writeln(ans);
end.

