#include <bits/stdc++.h>
using namespace std;
const int INF = 0x7f7f7f7f;
int main() {
  int p;
  while (~scanf("%d", &p)) {
    int k, j, c = 0;
    for (int i = 1; i < p; i++) {
      k = 1;
      for (j = 1;; j++) {
        k *= i;
        k %= p;
        if (k % p == 1) break;
      }
      if (j == p - 1) c++;
    }
    cout << c << endl;
  }
  return 0;
}
