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