#include <bits/stdc++.h>
int intcmp(const void *f, const void *s) { return (*(int *)f - *(int *)s); }
int gcd(int a, int b) { return ((b == 0) ? a : gcd(b, a % b)); }
int preprocess() { return 0; }
int main() {
  int i, j, n;
  int p;
  int ans = 0;
  scanf("%d", &p);
  for (i = 1; i < p; ++i) {
    int res = 1;
    for (j = 1; j < p; ++j) {
      res = (res * i) % p;
      if (res == 1) break;
    }
    if (j == p - 1) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
