#include <bits/stdc++.h>
using namespace std;
template <class T>
void chmax(T& l, const T r) {
  l = max(l, r);
}
template <class T>
void chmin(T& l, const T r) {
  l = min(l, r);
}
void reader(int& x) {
  int k, m = 0;
  x = 0;
  for (;;) {
    (k) = getchar_unlocked();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar_unlocked();
    if (k < '0' || k > '9') break;
    x = x * 10 + k - '0';
  }
  if (m) x = -x;
}
void reader(long long& x) {
  int k, m = 0;
  x = 0;
  for (;;) {
    (k) = getchar_unlocked();
    if (k == '-') {
      m = 1;
      break;
    }
    if ('0' <= k && k <= '9') {
      x = k - '0';
      break;
    }
  }
  for (;;) {
    (k) = getchar_unlocked();
    if (k < '0' || k > '9') break;
    x = x * 10 + k - '0';
  }
  if (m) x = -x;
}
int reader(char c[]) {
  int i, s = 0;
  for (;;) {
    (i) = getchar_unlocked();
    if (i != ' ' && i != '\n' && i != '\r' && i != '\t' && i != EOF) break;
  }
  c[s++] = i;
  for (;;) {
    (i) = getchar_unlocked();
    if (i == ' ' || i == '\n' || i == '\r' || i == '\t' || i == EOF) break;
    c[s++] = i;
  }
  c[s] = '\0';
  return s;
}
template <class T, class S>
void reader(T& x, S& y) {
  reader(x);
  reader(y);
}
template <class T, class S, class U>
void reader(T& x, S& y, U& z) {
  reader(x);
  reader(y);
  reader(z);
}
template <class T, class S, class U, class V>
void reader(T& x, S& y, U& z, V& w) {
  reader(x);
  reader(y);
  reader(z);
  reader(w);
}
void writer(int x, char c) {
  int s = 0, m = 0;
  char f[10];
  if (x < 0) m = 1, x = -x;
  while (x) f[s++] = x % 10, x /= 10;
  if (!s) f[s++] = 0;
  if (m) putchar_unlocked('-');
  while (s--) putchar_unlocked(f[s] + '0');
  putchar_unlocked(c);
}
void writer(long long x, char c) {
  int s = 0, m = 0;
  char f[20];
  if (x < 0) m = 1, x = -x;
  while (x) f[s++] = x % 10, x /= 10;
  if (!s) f[s++] = 0;
  if (m) putchar_unlocked('-');
  while (s--) putchar_unlocked(f[s] + '0');
  putchar_unlocked(c);
}
void writer(const char c[]) {
  int i;
  for (i = 0; c[i] != '\0'; i++) putchar_unlocked(c[i]);
}
void writer(const char x[], char c) {
  int i;
  for (i = 0; x[i] != '\0'; i++) putchar_unlocked(x[i]);
  putchar_unlocked(c);
}
template <class T>
void writerLn(T x) {
  writer(x, '\n');
}
template <class T, class S>
void writerLn(T x, S y) {
  writer(x, ' ');
  writer(y, '\n');
}
template <class T, class S, class U>
void writerLn(T x, S y, U z) {
  writer(x, ' ');
  writer(y, ' ');
  writer(z, '\n');
}
template <class T>
void writerArr(T x[], int n) {
  if (!n) {
    putchar_unlocked('\n');
    return;
  }
  for (int i = 0; i < (n - 1); i++) writer(x[i], ' ');
  writer(x[n - 1], '\n');
}
bool prime[1000001];
vector<int> prs;
void init_prime() {
  memset(prime, 1, sizeof(prime));
  prime[0] = prime[1] = false;
  for (int i = 2; i < sizeof(prime); i++)
    if (prime[i])
      for (int j = i * 2; j < sizeof(prime); j += i) prime[j] = false;
  for (int i = 2; i < sizeof(prime); i++)
    if (prime[i]) prs.push_back(i);
}
bool is_prime(long long n) {
  for (long long p : prs) {
    if (p * p > n) return true;
    if (n % p == 0) return false;
  }
  return true;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
int greedy(int n) {
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int cur = 0;
    for (int k = 1; k <= i; k++)
      if (i % k == 0 && gcd(k, i / k) == 1) cur += k;
    if (cur == n) ans++;
  }
  return ans;
}
bool can_div[((int)1e6)];
int f(long long a) {
  if (a == 1) return 1;
  if (a == 2) return 0;
  for (int i = 1; i < ((int)1e6); i++) {
    if (i > a) break;
    if (a % i == 0) {
      can_div[i] = true;
    }
  }
  map<long long, int> mp;
  mp[a] = 1;
  for (long long p : prs) {
    map<long long, int> add;
    for (long long np = p; np < a; np *= p) {
      const long long b = np + 1;
      if (b < ((int)1e6)) {
        if (!can_div[b]) continue;
      } else {
        if (a % b != 0) continue;
      }
      for (auto it = mp.rbegin(); it != mp.rend(); ++it) {
        auto& kv = *it;
        if (kv.first < b) break;
        if (kv.first % b == 0) {
          add[kv.first / b] += kv.second;
        }
      }
    }
    for (auto kv : add) {
      mp[kv.first] += kv.second;
    }
  }
  long long ans = 0;
  ans += mp[1];
  for (auto kv : mp) {
    if (kv.first <= ((int)1e6)) continue;
    long long x = kv.first - 1;
    if (is_prime(x)) ans += kv.second;
  }
  return ans;
}
int main() {
  init_prime();
  long long a;
  cin >> a;
  int ans = f(a);
  cout << ans << endl;
}
