#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k = 0, p, a[2001], len = 0;
  cin >> p;
  if (p == 2) {
    cout << "1" << endl;
    return 0;
  }
  for (i = 2; i < p; i++) {
    j = i;
    for (k = 1; k < p - 1; k++) {
      if ((j - 1) % p == 0) k = p;
      j = (j * i) % p;
    }
    if (k == p - 1 && (j - 1) % p == 0) len++;
  }
  cout << len << endl;
  return 0;
}
