#include <bits/stdc++.h>
using ll = long long;
using namespace std;
int p;
ll power(ll base, ll exp) {
  if (exp == 0) return 1;
  if (exp == 1) return base % p;
  ll t = power(base, exp / 2);
  t = (t * t) % p;
  if (exp % 2 == 0)
    return t;
  else
    return ((base % p) * t) % p;
}
int main() {
  cin >> p;
  int ans = 0;
  for (int i = 1; i < p; i++) {
    bool t = true;
    for (int j = 1; j <= p - 2; j++) {
      if (power(i, j) == 1) {
        t = false;
        break;
      }
    }
    if (t && power(i, p - 1) == 1) ans++;
  }
  cout << ans;
}
