#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 
// �f��������O(n^(1/2))
map<ll, ll> prime_factor(ll n){
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++){
        while (n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

vector<ll> divisor(ll n){
    vector<ll> res;
    for (ll i = 1; i * i <= n; i++){
        if (n % i == 0){
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}

int main() {
    ll N;
    cin >> N;
    map<ll, ll> primes2 = prime_factor(N);
    map<ll, ll> primes = prime_factor(N - 1);
    vector<ll> res = divisor(N);

#if 0
    int ans2 = 0;
    reps(d, 2, N){
        ll tmp = N;
        while(1){
            if (tmp % d == 0){
                tmp/= d;
            } else {
                if (tmp % d == 1){
                    fprintf(stderr, "d = %d\n", d);
                    ans2++;
                }
                break;
            }
        }
    }
    exit(1);
#endif
#if 0
    for (auto it = primes.begin(); it != primes.end(); ++it){
        cout << it->first << "^" << it->second << " * ";
    }
    cout << endl;
    
    for (auto it = primes2.begin(); it != primes2.end(); ++it){
        cout << it->first << "^" << it->second << " * ";
    }
    cout << endl;
    cout << N/9 %9 << endl;
    cout << N/349 %349 << endl;
#endif
    ll aa = 1, ans = 1; // = N
    for (auto it = primes.begin(); it != primes.end(); ++it){
        aa *= (it->second + 1);
    }
    ans += aa - 1;
    
    
    for (ll k: res){
        if (k == 1 || k == N)continue;
        ll tmp = N;
        while(1){
            if (tmp % k == 0){
                tmp/= k;
            } else {
                if (tmp % k == 1){
                    //fprintf(stderr, "d = %d\n", d);
                    ans++;
                }
                break;
            }
        }
    }
    cout << ans;
    return 0;
        
        
    for (auto it = primes2.begin(); it != primes2.end(); ++it){
        ll mul = 1;
        rep(i, it->second){
            mul *= it->first;
            ll tmp = N;
            while(1){
                if (tmp % mul == 0){
                    tmp/= mul;
                } else {
                    if (tmp % mul == 1){
                        //fprintf(stderr, "mul = %d\n", mul);
                        if (mul != N)
                        ans++;
                    }
                    break;
                }
            }
        }
    }
    cout << ans;
   return 0;
}



Measured memory_bytes: 384