#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, c = 0, i, j;
  cin >> n;
  for (i = 1; i <= n - 1; i++) {
    bool b = true;
    for (j = 1; j <= n - 2; j++)
      if (power(i, j, n) == 1) {
        b = false;
        break;
      }
    if (b && power(i, n - 1, n) == 1) c++;
  }
  cout << c;
}
