#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % mod; a = a * a % mod; }return res; }
//ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt {
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M& set_v(uint _v)
	{
        v = (_v < MD) ? _v : _v - MD;
        return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M& r) const { return M().set_v(v + r.v); }
	M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M& r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M& r) const { return *this * r.inv(); }
	M& operator+=(const M& r) { return *this = *this + r; }
	M& operator-=(const M& r) { return *this = *this - r; }
	M& operator*=(const M& r) { return *this = *this * r; }
	M& operator/=(const M& r) { return *this = *this / r; }
	bool operator==(const M& r) const { return v == r.v; }
	M pow(ll n) const
    {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
	M inv() const { return pow(MD - 2); }
	friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt;
//head

const int MAX_FACTOR_NUM = 20;
//辗转相除法求解a,b的最大公约数，使用前a、b请自行取绝对值
long long gcd(long long a, long long b)
{
	/*    if(b==0) return a;*/
		//return gcd(b,a%b);

	if (a == 0)  return 1;
	if (a < 0)    return gcd(-a, b);
	while (b)
	{
		ll t = a % b;
		a = b;
		b = t;
	}
	return a;
}

map<long long, int> factor_num; //key:因子的值，value:因子的幂

ll multi_mod(ll a, ll b, ll n)
{
	a %= n;
	b %= n;
	ll res = 0;
	while (b)
	{
		if (b & 1)
		{
			res += a;
			if (res >= n) res -= n;
		}
		a <<= 1;
		if (a >= n) a -= n;
		b >>= 1;
	}
	return res;
}

ll pow_mod(ll x, ll n, ll mod)
{
	if (n == 1)  return x % mod;
	x %= mod;

	ll tmp = x;
	ll res = 1;
	while (n > 0)
	{
		if (n & 1)   res = multi_mod(res, tmp, mod);
		tmp = multi_mod(tmp, tmp, mod);
		n >>= 1;
	}
	return res;
}

bool witness(ll a, ll n, ll u, ll t)
{
	ll res = pow_mod(a, u, n);
	ll last = res;
	for (int i = 0; i < t; i++)
	{
		res = multi_mod(res, res, n);
		if (res == 1 && last != 1 && last != n - 1)    return true;
		last = res;
	}
	if (res != 1)    return true;
	else        return false;
}

bool robin_miller(ll n) //判断是否素数
{
	if (n < 2)    return false;
	if (n == 2)  return true;
	if (!(n & 1))    return false;

	ll u = n - 1, t = 0;
	while (!(u & 1)) u >>= 1, t++;
	if (t >= 1 && (u & 1) == 1)
	{
		for (int i = 0; i < MAX_FACTOR_NUM; i++)
		{
			ll a = rand() % (n - 1) + 1;
			if (witness(a, n, u, t)) return false;   //不是素数
		}
	}
	return true;    //是素数
}

ll pollard_rho(ll x, ll c)
{
	ll i = 1, x0 = rand() % x;
	ll y = x0;
	ll k = 2;
	for (;;)
	{
		i++;
		x0 = (multi_mod(x0, x0, x) + c) % x;
		ll d = gcd(y - x0, x);  //这里传给gcd的参数可能负数，注意分别讨论
		if (d != 1 && d != x) return d;  //这里表明找到了一个因子
		if (y == x0) return x;
		if (i == k)
		{
			y = x0;
			k += k;
		}
	}
}

void find_fac(long long n)
{
	if (n == 1)    return;
	if (robin_miller(n))
	{
		factor_num[n] = 0;
		return;
	}
	long long p = n;
	while (p >= n) p = pollard_rho(p, rand() % (n - 1) + 1);
	find_fac(p);
	find_fac(n / p);
}

int solve(long long tt)
{
	factor_num.clear();

	find_fac(tt);
	//for(int i=0;i<cnt;++i){
		//cout<<factor[i]<<"-->"<<factor_num[i]<<endl;
	//}
	map<ll, int>::iterator iter;
	ll factor[MAX_FACTOR_NUM];
	int cnt = 0;
	for (iter = factor_num.begin(); iter != factor_num.end(); ++iter) {
		factor[cnt++] = iter->first;
	}
	//cout<<"cnt="<<cnt<<endl;

	ll t = tt;
	for (int i = 0; i < cnt; ++i) {
		while (t % factor[i] == 0) {
			factor_num[factor[i]]++;
			t /= factor[i];
		}
		//cout<<factor[i]<<"-->"<<factor_num[factor[i]]<<endl;
	}

	ll ccc = 1;
	for (iter = factor_num.begin(); iter != factor_num.end(); ++iter) {
		//cout << iter->first << " " << iter->second << endl;
		ccc *= ((ll)iter->second+1);
	}
	return ccc;
}

int main()
{
    ios::sync_with_stdio(false);
#ifdef RG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
#endif

	ll n;
	cin >> n;
	ll ans = solve(n-1);
	ans--;
	//cout << cc << endl;
	for (ll k= 2; k * k <= n; ++k) {
		if (n % k == 0) {
			ll nn = n;
			while (nn % k == 0) nn /= k;
			if (nn % k == 1) ans++;
		}
	}
	//n itself
	ans++;
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256