#include <bits/stdc++.h>
using namespace std;
long long exp(long long x, long long y, long long p) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % p) % p;
    x = (x * x) % p;
    y /= 2;
  }
  return res;
}
long long expm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y % 2) res = (res * x % ((long long)1e9 + 7)) % ((long long)1e9 + 7);
    x = (x * x) % ((long long)1e9 + 7);
    y /= 2;
  }
  return res;
}
long long add(long long x, long long y) {
  x += y;
  if (x >= ((long long)1e9 + 7)) return x - ((long long)1e9 + 7);
  return x;
}
long long sub(long long x, long long y) {
  x -= y;
  if (x < 0) return x + ((long long)1e9 + 7);
  return x;
}
long long mult(long long x, long long y) {
  return (x * y) % ((long long)1e9 + 7);
}
long long rev(long long x) { return expm(x, ((long long)1e9 + 7) - 2); }
void solve() {
  long long p;
  cin >> p;
  long long ans = 0;
  for (long long i = 1; i < p; i++) {
    bool ok = 1;
    for (long long j = 1; j < p - 1; j++) {
      if ((exp(i, j, p) - 1) % p == 0) ok = 0;
    }
    if (ok && (exp(i, p - 1, p) - 1) % p == 0) ans++;
  }
  cout << ans;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  { solve(); }
  return 0;
}
