#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int main() {
  ios::sync_with_stdio(false);
  int p, res = 1;
  cin >> p;
  --p;
  for (int i = 2; i * i <= p; ++i)
    if (p % i == 0) {
      res *= i - 1;
      p /= i;
      while (p % i == 0) res *= i, p /= i;
    }
  if (p - 1) res *= p - 1;
  cout << res << endl;
  return 0;
}
