#include <bits/stdc++.h>
inline int phi(const int &n) {
  int x = n, res = 1;
  for (int i = 2; i * i <= n; ++i)
    if (x % i == 0) {
      x /= i;
      res *= i - 1;
      while (x % i == 0) res *= i, x /= i;
    }
  if (x > 1) res *= x - 1;
  return res;
}
int main() {
  int p;
  while (~scanf("%d", &p)) printf("%d\n", phi(phi(p)));
  return 0;
}
