#include <bits/stdc++.h>
using namespace std;
const double pi = (2 * acos(0));
struct point {
  long double x, y;
};
double area(int x1, int y1, int x2, int y2, int x3, int y3) {
  double a =
      (x2 * y3) - (x3 * y2) - (x1 * y3) + (x3 * y1) + (x1 * y2) - (x2 * y1);
  a /= 2;
  return fabs(a);
}
long double anyarea(point p[], int n) {
  long double sum1 = p[n - 1].x * p[0].y, sum2 = p[n - 1].y * p[0].x;
  for (int i = 0; i < n - 1; i++) {
    sum1 += p[i].x * p[i + 1].y;
    sum2 += p[i].y * p[i + 1].x;
  }
  return fabs((sum1 - sum2) * 0.5);
}
long long fastpow(long long base, long long p, long long m) {
  if (p == 0) return 1;
  long long ans = fastpow(base, p / 2, m);
  ans = ((ans % m) * (ans % m)) % m;
  if (p % 2) ans = ((base % m) * ans) % m;
  return ans;
}
long long GCD(int M, int m) {
  if (M % m == 0) return m;
  M %= m;
  int x1 = M, x2 = m;
  m = min(x1, x2);
  M = max(x1, x2);
  return GCD(M, m);
}
map<int, int> mp;
int spead(int &x, int s, int m) {
  x = (spead(x, s, m) % m + s % m) % m;
  mp[x]++;
  return x;
}
int main() {
  long long p, ans = 0;
  cin >> p;
  for (int x = 1; x < p; x++) {
    bool c = true;
    if ((fastpow(x, (p - 1), p) - 1) % p != 0) x = false;
    if (c == true) {
      for (int i = 1; i < p - 1; i++)
        if ((fastpow(x, i, p) - 1) % p == 0) {
          c = false;
          break;
        }
    }
    if (c == true) ans++;
  }
  cout << ans;
}
