#include <bits/stdc++.h>
using namespace std;
int main() {
  int p;
  cin >> p;
  int res = 0;
  for (int x = 1; x < p; x++) {
    bool ok = true;
    int m = 1;
    for (int j = 1; j < p - 1; j++) {
      (m *= x) %= p;
      if ((m - 1) % p == 0) ok = false;
    }
    if (ok) res++;
  }
  cout << res << endl;
  return 0;
}
