#include <bits/stdc++.h>
using namespace std;
int el(int x) {
  int m = x, t = sqrt(x + 0.5);
  for (long long i = 2; i <= t; i++) {
    if (x % i == 0) {
      m = m / i * (i - 1);
      while (x % i == 0) {
        x /= i;
      }
    }
  }
  if (x != 1) m = m / x * (x - 1);
  return m;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    int x = el(n - 1);
    printf("%d\n", x);
  }
  return 0;
}
