#include <bits/stdc++.h>
using namespace std;
const int NMAX = 3100;
int N, cnt;
int main() {
  cin >> N;
  for (int x = 1; x < N; x++) {
    int x1 = 1, j = 1;
    for (j; j < N; j++) {
      x1 *= x;
      x1 %= N;
      if ((x1 - 1) % N == 0) break;
    }
    if (j == N - 1) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
