#include <bits/stdc++.h>
using namespace std;
void RD(int &x) { scanf("%d", &x); }
void RD(long long &x) { scanf("%I64d", &x); }
void RD(unsigned int &x) { scanf("%u", &x); }
void RD(double &x) { scanf("%lf", &x); }
void RD(int &x, int &y) { scanf("d", &x, &y); }
void RD(long long &x, long long &y) { scanf("I64d", &x, &y); }
void RD(unsigned int &x, unsigned int &y) { scanf("u", &x, &y); }
void RD(double &x, double &y) { scanf("lf", &x, &y); }
void RD(int &x, int &y, int &z) { scanf("d%d", &x, &y, &z); }
void RD(long long &x, long long &y, long long &z) {
  scanf("I64d%I64d", &x, &y, &z);
}
void RD(unsigned int &x, unsigned int &y, unsigned int &z) {
  scanf("u%u", &x, &y, &z);
}
void RD(double &x, double &y, double &z) { scanf("lf%lf", &x, &y, &z); }
void RD(char &x) { x = getchar(); }
void RD(char *s) { scanf("%s", s); }
void RD(string &s) { cin >> s; }
void PR(int x) { printf("%d\n", x); }
void PR(long long x) { printf("%I64d\n", x); }
void PR(unsigned int x) { printf("%u\n", x); }
void PR(double x) { printf("%.6lf\n", x); }
void PR(char x) { printf("%c\n", x); }
void PR(char *x) { printf("%s\n", x); }
void PR(string x) { cout << x << endl; }
long long f[5005], phi[5005];
void init() {
  for (int i = 1; i < 5005; i++) phi[i] = i;
  for (int i = 2; i < 5005; i += 2) phi[i] /= 2;
  for (int i = 3; i < 5005; i += 2) {
    if (phi[i] == i) {
      for (int j = i; j < 5005; j += i) {
        phi[j] = phi[j] / i * (i - 1);
      }
    }
  }
  for (int i = 2; i < 5005; i++) {
    f[i] = f[i - 1] + phi[i];
  }
}
int jisuan(int x) {
  int i, res = x;
  for (i = 2; i < (int)sqrt(x * 1.0) + 1; i++)
    if (x % i == 0) {
      res = res / i * (i - 1);
      while (x % i == 0) x /= i;
    }
  if (x > 1) res = res / x * (x - 1);
  return res;
}
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    printf("%d\n", jisuan(n - 1));
  }
  return 0;
}
