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