#include<bits/stdc++.h>
using namespace std;

// macros
#define int long long 
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define PB push_back
#define MP make_pair
#define bitcount __builtin_popcount
#define watch(x) cerr<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef long double ld;

// template functions
template < typename A, typename B >
ostream &operator << ( ostream& os, const pair< A, B > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}
template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "[";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}
template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "{";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}
template < typename A, typename B >
ostream &operator << ( ostream & os, const map< A, B > &v ) {
    os << "[";
    typename map< A, B >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " -> " << it -> second ;
    }
    return os << "]";
}
template<typename T>
T gcd(T a, T b) { if(a==0 or b==0) return a+b; return gcd(b, a%b) ; }
template<typename T>
T lcm(T a, T b) { if(a==0 or b==0) return 0; return a/gcd(a, b)*b; }

// random number generation
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// constants
const long double eps = LDBL_EPSILON;
const int inf = 1e15;
const int modn = 1e9+7;
const int maxn = 2e6+3;

int no_of_divi(int n) {
    int tmp = n;
    int res = 1;
    for(int i=2; i*i<=tmp; i++) {
        if(tmp%i==0) {
            int c = 0;
            while(tmp%i==0) {
                c++;
                tmp /= i;
            }
            // p.PB(MP(i, c));
            res *= (1 + c);
        }
    }
    if(tmp > 1) res *= 2;
    return res;
}

vi find_alldiv(vector<pii > p) {
    vi ans;
    function<void(int, int) > solve = [&](int i, int cur) {
        if(i==sz(p)) {
            ans.PB(cur);
            return;
        }

        int pr = p[i].first;
        int c = p[i].second;
        int nex = 1;
        for(int j=0; j<=c; j++) {
            solve(i+1, cur*nex);
            nex *= pr;
        }
    };
    solve(0, 1);
    return ans;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
    // watch(find_alldiv({MP(2, 2), MP(3, 1)}));
    int n;
    cin>>n;
    int tmp = n;
    vector<pii > p;
    for(int i=2; i*i<=tmp; i++) {
        if(tmp%i==0) {
            int c = 0;
            while(tmp%i==0) {
                c++;
                tmp /= i;
            }
            p.PB(MP(i, c));
        }
    }
    if(tmp > 1) p.PB(MP(tmp, 1));
    int cnt = no_of_divi(n-1);
    int ans = cnt-1;
    vi alldiv = find_alldiv(p);
    for(int val : alldiv) {
        if(val==1) continue;
        tmp = n;
        while(tmp%val==0) {
            tmp/=val;
        }
        if((tmp-1)%val==0) {
            ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 384