// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#ifdef on_linux
#include <sys/resource.h>
#endif

using namespace std;
using namespace __gnu_pbds;

#define sz(x)                   (int)((x).size())
#define all(x)                  (x).begin(), (x).end()
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define sleep(x)                std::this_thread::sleep_for(std::chrono::milliseconds(x))
#define DECIMAL(n)              std::cout << std::fixed << std::setprecision(n);
#define rep(i,a,b)              for(int32_t i = (a); i < (b); ++i)
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
// #define clamp(i,x,y)         clamp(i, x, y)
#define sqr(a)                  ((a) * (a))
#define pii                     pair<int32_t, int32_t>
#define pll                     pair<long long, long long>
#define mp                      make_pair
#define fi                      first
#define sc                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define lbd                     lower_bound
#define ubd                     upper_bound
#define int                     long long
#define ll                      long long

template<typename T, typename U> istream& operator>>(istream& in, pair<T, U> &a) {in >> a.first >> a.second; return in;}
template<typename T, typename U> ostream& operator<<(ostream& out, pair<T, U> a) {out << "{" << a.first << ", " << a.second << "}"; return out;}
template<typename T, typename U> static inline void remin(T &x, U y) {if (y < x) {x = y;}}
template<typename T, typename U> static inline void remax(T &x, U y) {if (x < y) {x = y;}}

static mt19937_64 gen(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());

inline long long toint(const string &s) {stringstream ss; ss << s; long long x; ss >> x; return x;}
inline string tostring(long long number) {stringstream ss; ss << number; return ss.str();}
inline string tobin(long long x) {return bitset<63>(x).to_string();}

void alllower(string &u) {transform(u.begin(), u.end(), u.begin(), ::tolower); return;}
void allupper(string &u) {transform(u.begin(), u.end(), u.begin(), ::toupper); return;}

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase, insert same as normal set

const long double PI = 3.14159265358979323846264338;
const long double eps = 1e-12;
const long long fftmod = 998244353;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int32_t N = 1e5 + 10;
const int32_t NN = 1e6 + 10;

vector<pair<int, int32_t>> primefactors;
void primeFactors(int n)
{
	primefactors.clear();
	int cnt = 0;
	while (n % 2 == 0) {
		n = n / 2;
		cnt++;
	}
	if (cnt)
		primefactors.pb({2, cnt});
	for (int i = 3; i * i <= n; i += 2) {
		cnt = 0;
		while (n % i == 0) {
			cnt++;
			n /= i;
		}
		if (cnt)
			primefactors.pb({i, cnt});
	}
	if (n > 2)
		primefactors.pb({n, 1});
}

inline void dobbysolver(int testcase)
{
	int n;
	cin >> n;
	int ans = 0;
	int ex = 0;
	for (int i = 2; i < NN; ++i) {
		int nc = n;
		if (nc % i == 0) {
			while (nc % i == 0)
				nc /= i;
			if (nc % i == 1) ans++;
		}
		else if (nc % i == 1) ex++;
	}
	if (n < NN) {
		cout << ans + ex;
		return;
	}
	// cout << ans << endl;
	ans++;	// i = n
	primeFactors(n - 1);
	int c = 1;
	for (auto i : primefactors)
		c *= (i.sc + 1);
	c--;	// not 1
	ans += c;
	cout << ans;
	return;
}

int32_t main()
{
#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		dobbysolver(i);
		if (i != TESTS)	cout << '\n';
	}
	return 0;
}

Measured memory_bytes: 256