#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, i, j;
  cin >> n;
  int sum = 0;
  if (n == 2) {
    cout << "1";
    return 0;
  }
  for (i = 2; i < n; i++) {
    int prod = 1;
    for (j = 1; j < n; j++) {
      prod = (prod * i) % n;
      if (prod == 1) break;
    }
    if (j == n - 1) sum++;
  }
  cout << sum;
  return 0;
}
