#include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <tuple>
#include <type_traits>
#include <vector>

// lib/quo.hpp
#ifndef QUO_H
#define QUO_H

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

namespace tools {
  template <typename T>
  constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
}

#endif

// lib/prime_factorization.hpp
#ifndef PRIME_FACTORIZATION_HPP
#define PRIME_FACTORIZATION_HPP


namespace tools {
  template <typename T>
  ::std::map<T, T> prime_factorization(T n) {
    ::std::map<T, T> result;

    const T floor_sqrt_n = static_cast<T>(::std::sqrt(n));
    for (T i = static_cast<T>(2); i <= floor_sqrt_n; ++i) {
      while (n % i == static_cast<T>(0)) {
        ++result[i];
        n /= i;
      }
    }

    // if n is a prime
    if (n > static_cast<T>(1)) {
      ++result[n];
    }

    return result;
  }
}

#endif

// lib/monoid.hpp
#ifndef MONOID_HPP
#define MONOID_HPP


namespace tools {
  template <typename T>
  class monoid {
  private:
    ::std::function<T(T, T)> m_operation;
    T m_identity;

  public:
    monoid(const ::std::function<T(T, T)>& operation, const T& identity) :
      m_operation(operation),
      m_identity(identity) {
    }
    monoid(const ::tools::monoid<T>&) = default;
    monoid(::tools::monoid<T>&&) = default;
    ::tools::monoid<T>& operator=(const ::tools::monoid<T>&) = default;
    ::tools::monoid<T>& operator=(::tools::monoid<T>&&) = default;
    virtual ~monoid() = default;

    T operation(const T& x, const T& y) const {
      return this->m_operation(x, y);
    }
    const T& identity() const {
      return this->m_identity;
    }

    template <typename U = T, typename ::std::enable_if<::std::is_integral<U>::value, ::std::nullptr_t>::type = nullptr>
    static ::tools::monoid<U> multiplies() {
      return ::tools::monoid<U>(::std::multiplies<U>(), 1);
    }
  };
}

#endif

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// lib/divisors.hpp
#ifndef DIVISORS_HPP
#define DIVISORS_HPP


namespace tools {
  template <typename T>
  ::std::vector<T> divisors(const T& n) {
    ::std::vector<T> head;
    ::std::vector<T> tail;

    const T ceil_sqrt_n = static_cast<T>(::std::ceil(::std::sqrt(n)));
    for (T i = static_cast<T>(1); i < ceil_sqrt_n; ++i) {
      if (n % i == static_cast<T>(0)) {
        head.push_back(i);
        tail.push_back(n / i);
      }
    }

    // if n is a square number
    if (ceil_sqrt_n * ceil_sqrt_n == n) {
      head.push_back(ceil_sqrt_n);
    }

    ::std::copy(tail.rbegin(), tail.rend(), ::std::back_inserter(head));
    return head;
  }
}

#endif

// lib/extgcd.hpp
#ifndef EXTGCD_HPP
#define EXTGCD_HPP


/*
usage:

std::tuple<int, int, int> result = tools::extgcd(4, 5);
int gcd = std::get<0>(result);
int x0 = std::get<1>(result);
int y0 = std::get<2>(result);
*/

namespace tools {
  template <typename T>
  std::tuple<T, T, T> extgcd(T prev_r, T r) {
    T prev_s = 1;
    T prev_t = 0;
    T s = 0;
    T t = 1;
    while (r != 0) {
      const T q = quo(prev_r, r);
      const T next_r = prev_r - q * r;
      prev_r = r;
      r = next_r;
      const T next_s = prev_s - q * s;
      prev_s = s;
      s = next_s;
      const T next_t = prev_t - q * t;
      prev_t = t;
      t = next_t;
    }
    return std::make_tuple(std::abs(prev_r), prev_s, prev_t);
  }
}

#endif

// lib/square.hpp
#ifndef SQUARE_HPP
#define SQUARE_HPP


/*
usage:

tools::square(5) => 25
*/

namespace tools {
  template <typename T>
  T square(const ::tools::monoid<T>& monoid, const T& x) {
    return monoid.operation(x, x);
  }

  template <typename T>
  T square(const T& x) {
    return ::tools::square(::tools::monoid<T>::multiplies(), x);
  }
}

#endif

// lib/pow.hpp
#ifndef POW_H
#define POW_H


/*
usage:

tools::pow(tools::monoid<int>::multiplies(), 2, 5) => 32
*/

namespace tools {
  template <typename T>
  T pow(const ::tools::monoid<T>& monoid, const T& base, const std::size_t exponent) {
    return exponent == 0
      ? monoid.identity()
      : exponent % 2 == 0
        ? ::tools::square(monoid, ::tools::pow(monoid, base, exponent / 2))
        : monoid.operation(::tools::pow(monoid, base, exponent - 1), base);
  }

  template <typename T>
  T pow(const T& base, const std::size_t exponent) {
    return ::tools::pow(::tools::monoid<T>::multiplies(), base, exponent);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;

  // N = K^m (nK + 1) (n >= 0, m >= 0, n + m >= 1)
  std::unordered_set<i64> answers;

  std::vector<std::pair<i64, i64>> prime_factors;
  {
    const std::map<i64, i64> prime_factor_map = tools::prime_factorization(N);
    std::copy(prime_factor_map.begin(), prime_factor_map.end(), std::back_inserter(prime_factors));
  }

  std::vector<std::pair<i64, i64>> divisor;
  std::function<void(void)> dfs;
  dfs = [&]() {
    if (divisor.size() == prime_factors.size()) {
      if (std::all_of(divisor.begin(), divisor.end(), [](const std::pair<i64, i64>& pair) { return pair.second == 0; })) {

        // m = 0 の場合:
        // N = nK + 1
        // N - 1 = nK
        // よって、K は N - 1 の約数（ただし1は除く）

        std::vector<i64> divisors = tools::divisors(N - 1);
        std::copy(divisors.begin(), divisors.end(), std::inserter(answers, answers.end()));
        answers.erase(1);

      } else {

        // m > 0 の場合:
        const i64 gcd = std::accumulate(divisor.begin(), divisor.end(), static_cast<i64>(0), [&](const i64& g, const std::pair<i64, i64>& pair) { return std::get<0>(tools::extgcd(g, pair.second)); });
        for (const i64& m : tools::divisors(gcd)) {
          i64 K = 1;
          for (const std::pair<i64, i64>& pair : divisor) {
            K *= tools::pow(pair.first, pair.second / m);
          }

          // N / K^m = nK + 1 が成り立てば、K は題意を満たす
          if (N / tools::pow(K, m) % K == 1) {
            answers.insert(K);
          }
        }
      }
    } else {
      for (i64 i = 0; i <= prime_factors[divisor.size()].second; ++i) {
        divisor.push_back(std::make_pair(prime_factors[divisor.size()].first, i));
        dfs();
        divisor.pop_back();
      }
    }
  };
  dfs();

  std::cout << answers.size() << std::endl;
  return 0;
}

Measured memory_bytes: 3800