#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);

using namespace std;
typedef long long int  ll;
typedef pair<int, int> P;


//lcm//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//a^n mod p//
ll modpow(ll a, ll n, ll p) {
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
  ll t = modpow(a, n / 2, p);
  return (t * t) % p;
}

//inversemod//
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
// 
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 
ll COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//LARGE n
ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}
	return k;
}


////////////////////////////////////////////////////////////////////

int main() {
ll n;
cin>>n;
ll m=n;

vector <ll> vec;
for (ll i = 1; i*i <= m; i++) {
	if (m%i == 0) {
		vec.push_back(i);
		vec.push_back(m / i);
		
	}
}


vector <ll> ve;
while (m >= 2) {
	bool so = true;
	for (ll i = 2; i*i <= m; i++) {
		if (m%i == 0) {
			ve.push_back(i);
			m /= i;
			so = false;
			break;
		}
	}
	if (so) {
		ve.push_back(m);
		break;
	}
}




sort(ALL(ve));

map <ll, ll> mp{};
for(int i=0;i<ve.size();i++){
if(!mp.count(ve[i])){
	mp[ve[i]]=1;
}
else{
	mp[ve[i]]++;
}
}



ll ans=0;
vector<ll> ansv{};
sort(ALL(vec));
for(ll uu=0;uu<vec.size();uu++){
	ll val=vec[uu];
	if(val==1) continue;

vector<ll> yak{};

while (val >= 2) {
	bool so = true;
	for (ll i = 2; i*i <= val; i++) {
		if (val%i == 0) {
			yak.push_back(i);
			val /= i;
			so = false;
			break;
		}
	}
	if (so) {
		yak.push_back(val);
		break;
	}
}

sort(ALL(yak));



map <ll, ll> mp1{};
for(int i=0;i<yak.size();i++){
if(!mp1.count(yak[i])){
	mp1[yak[i]]=1;
}
else{
	mp1[yak[i]]++;
}
}

ll maxind=999;

set<ll> se{};
for(int i=0;i<yak.size();i++){
se.insert(yak[i]);
}

for(int i=0;i<yak.size();i++){
ll x=mp[yak[i]];
ll y=mp1[yak[i]];
maxind=min(maxind,x/y);

}




for(ll i=1;i<=maxind+1;i++){
	ll kv=1;

	ll tt=1;
	for(auto itr=se.begin();itr!=se.end();++itr){
		ll u=*itr;
		tt*=modpow(u,mp1[u],(ll)100000000000000);
	}
	kv=modpow(tt,maxind,(ll)100000000000000);
ll nn=n;
nn/=kv;
if((nn-1)%tt==0){ansv.push_back(tt);}
}


}


sort(ALL(ansv));
map<ll, ll> mp2{};


ll nowv=0;
for(int i=0;i<ansv.size();i++){
	if(i==0){nowv=ansv[i];
	ans++;
	continue;}
	if(nowv!=ansv[i]){
		nowv=ansv[i];
		mp2[ansv[i]]=1;
		ans++;
	}
}


ll mpa=n-1;


vector <ll> vect{};
for (ll i = 1; i*i <= mpa; i++) {
	if (mpa%i == 0) {
		vect.push_back(i);
		if(i!=mpa/i){
		vect.push_back(mpa /i);}
	}
}

for(ll i=0;i<vect.size();i++){
	if(!mp2.count(vect[i]) && vect[i]!=1){
		ans++;
	}

}



cout<<ans<<endl;




return 0;
}




Measured memory_bytes: 384