#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, x, ans = 0;
  bool b;
  cin >> p;
  for (int i = 1; i < p; i++) {
    b = 1;
    x = 1;
    for (int j = 1; j < p - 1; j++) {
      x = (x * i) % p;
      if ((x - 1) % p == 0) b = 0;
    }
    if (((x * i) - 1) % p != 0) b = 0;
    if (b) ans++;
  }
  cout << ans << endl;
  return 0;
}
