#include <bits/stdc++.h>
long long fastpower(long long base, long long power, long long mod) {
  if (!power) return 1;
  long long left = fastpower(base, power / 2, mod);
  left *= left;
  left %= mod;
  if (power % 2 != 0)
    return (left * (base % mod)) % mod;
  else if (power % 2 == 0)
    return left;
}
using namespace std;
int main(void) {
  int p, cntr = 0;
  cin >> p;
  for (long long x = 1; x < p; x++) {
    bool div = true;
    for (int pow = 1; pow < (p - 1); ++pow) {
      if ((fastpower(x, pow, p) - 1) % p == 0) {
        div = false;
        break;
      }
    }
    if (div && (fastpower(x, p - 1, p) - 1) % p == 0) cntr++;
  }
  cout << cntr << endl;
}
