#include <bits/stdc++.h>
using namespace std;
int n, cnt;
int gcd(int a, int b) { return (b) ? gcd(b, a % b) : a; }
int main() {
  cin >> n;
  for (int i = 1; i < n; i++)
    if (gcd(i, n - 1) == 1) cnt++;
  cout << cnt;
}
