#include <bits/stdc++.h>
bool flag;
int n, ans = 0;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    int x = i;
    flag = 1;
    for (int j = 1; j <= n - 2; j++) {
      if ((x - 1) % n == 0) {
        flag = 0;
        break;
      }
      (x *= i) %= n;
    }
    if (!flag) continue;
    if ((x - 1) % n == 0) ans++;
  }
  printf("%d", ans);
  return 0;
}
