#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long A;
long long fact[20];
int factcnt[20], nfact;
typedef struct X {
  long long cur;
  int id;
  long long p;
} X;
bool operator<(const X &a, const X &b) { return a.p < b.p; }
X x[20000];
int nx;
void adddiv(long long cur, int id, long long p) {
  x[nx].cur = cur;
  x[nx].id = id;
  x[nx].p = p;
  ++nx;
}
void testdiv(long long cur, int id) {
  long long x = cur - 1;
  for (long long i = 2; i * i <= x; ++i)
    if (x % i == 0) {
      while (x % i == 0) x /= i;
      if (x == 1) adddiv(cur, id, i);
      return;
    }
  adddiv(cur, id, x);
}
void gendivs(long long cur, int at, int id) {
  if (at >= nfact) {
    if (cur >= 3) testdiv(cur, id);
    return;
  }
  for (int i = (0); i <= (factcnt[at]); ++i) {
    gendivs(cur, at + 1, id * (factcnt[at] + 1) + i);
    cur *= fact[at];
  }
}
long long ways[20000];
bool ok(int a, int b) {
  for (int i = nfact - 1; i >= 0; --i) {
    int aa = a % (factcnt[i] + 1);
    a /= factcnt[i] + 1;
    int bb = b % (factcnt[i] + 1);
    b /= factcnt[i] + 1;
    if (aa + bb > factcnt[i]) return false;
  }
  return true;
}
void run() {
  cin >> A;
  {
    long long x = A;
    for (long long i = 2; i * i <= x; ++i)
      if (x % i == 0) {
        fact[nfact] = i;
        factcnt[nfact] = 0;
        while (x % i == 0) factcnt[nfact]++, x /= i;
        ++nfact;
      }
    if (x != 1) fact[nfact] = x, factcnt[nfact] = 1, ++nfact;
  }
  nx = 0;
  gendivs(1, 0, 0);
  sort(x, x + nx);
  int start = 0;
  for (int i = (0); i < (nfact); ++i)
    start = start * (factcnt[i] + 1) + factcnt[i];
  memset(ways, 0, sizeof(ways));
  ways[0] = 1;
  int at = 0;
  while (at < nx) {
    int to = at;
    while (to < nx && x[at].p == x[to].p) ++to;
    for (int i = start - 1; i >= 0; --i)
      for (int j = (at); j < (to); ++j)
        if (ok(i, x[j].id)) ways[i + x[j].id] += ways[i];
    at = to;
  }
  cout << ways[start] << endl;
}
int main() {
  run();
  return 0;
}
