#include <bits/stdc++.h>
#define ll long long
using namespace std;
const long long mod = 1e9+7;
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
const int N = 3e5+9;
const int M = 1e6+2;
int lp[M]={};
vector<int> pr;
vector<pair<ll, int>> factorize(ll n, ll& no_of_factors) {
    if(pr.empty()) {
        for (int i = 2; i < M; i++) {
            if (lp[i] == 0) {
                lp[i] = i;
                pr.push_back(i);
            }
            for (int j = 0; j < (int) pr.size() && pr[j] <= lp[i] && i * pr[j] < M; j++) {
                lp[i * pr[j]] = pr[j];
            }
        }
    }
    vector<pair<ll, int>> factors;
    ll& ans = no_of_factors;
    ans = 1;
    if(n <= M) { // n ~ 1e6
        while(n > 1) {
            int p = lp[n];
            int cnt = 0;
            while(n % p == 0) {
                n /= p;
                cnt++;
            }
            factors.push_back({p, cnt});
            ans = ans * (cnt+1);
        }
        return factors;
    }
    if(n < 1.l * M * M * M) { // n ~ 1e12 to 1e18
        for(int p: pr) {
            int cnt = 0;
            while(n % p == 0) {
                n /= p;
                cnt++;
            }
            if(cnt > 0) {
                factors.push_back({p, cnt});
                ans *= (cnt+1);
            }
        }   
        if(n <= 1ll * M * M) { // n ~ 1e12
            if(n > 1) {
                factors.push_back({n, 1});
                ans *= 2;
            }
            return factors;
        }
        // n ~ 1e18
        ll sq = sqrt(n);
        if(sq * sq == n) {
            factors.push_back({sq, 2});
            ans *= 3;
        } else if((sq+1)*(sq+1) == n) {
            factors.push_back({sq+1, 2});
            ans *= 3;
        } else if((sq+2) * (sq+2) == n) {
            factors.push_back({sq+2, 2});
            ans *= 3;
        } else {
            ans *= 4;
            return vector<pair<ll, int>>();
        }
        return factors;
    }
    assert(0);
    return vector<pair<ll, int>>();
}
vector<pair<ll, int>> pfactors;
vector<ll> factors;
void generate(int ind, ll num) {
    int m = pfactors.size();
    if(ind == m) {
        factors.push_back(num);
        return;
    }
    ll p = pfactors[ind].first;
    int cnt = pfactors[ind].second;
    ll x = 1;
    for(int i = 0; i <= cnt; i++) {
        generate(ind+1, num * x);
        if(i < cnt) x *= p;
    }
}
signed main() {  

    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    ll n; cin >> n; 
    ll foo = 0;
    pfactors = factorize(n, foo);
    
    generate(0, 1);
    ll ans = 0;
    for(ll f: factors) {
        if(f == 1) continue;
        ll m = n;
        while(m % f == 0) m /= f;
        m %= f;
        if(m == 1) {
            ans++;
        }
    }
    // cout << "from facts: " << ans << endl;
    factorize(n-1, foo);
    foo -= 1;
    ans += foo;
    // cout << "from subs: " << foo << endl;
    cout << ans << endl;





    return 0;
    
}

Measured memory_bytes: 4860