#include <bits/stdc++.h>
using namespace std;
int Euler(int n) {
  int i, ret = n;
  for (i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      n /= i;
      ret = ret - ret / i;
      while (n % i == 0) n = n / i;
    }
  }
  if (n > 1) ret = ret - ret / n;
  return ret;
}
int main() {
  int p;
  cin >> p;
  cout << Euler(p - 1) << endl;
  return 0;
}
