#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int main() {
  int p;
  cin >> p;
  int n = 0;
  for (int(x) = (1); x < (p); ++(x)) {
    long long xx = x;
    bool b = 1;
    for (int(k) = (1); k < (p - 1); ++(k)) {
      if ((xx - 1) % p == 0) {
        b = false;
        break;
      }
      xx *= x;
      xx %= p;
    }
    if (b && (xx - 1) % p == 0) n++;
  }
  cout << n;
  return 0;
}
