/*
 #pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
*/
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#define DEBUG 0
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
#include <list>
#include <functional>
#include <numeric>

//find out the use of the below
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define PI acos(-1)
#define vpi vector<pair<long, int> >
long n, ans;
int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b%a,a);
}
vpi factorize(long num) {
    vpi res;
    for (long i = 2; i*i <= num; ++i) {
        if (num%i == 0){
            pair<long, int> pr = {i, 0};
            while (num%i == 0) {
                num/=i;
                pr.y++;
            }
            res.pb(pr);
        }
    }
    if (num > 1)
        res.pb({num, 1});

    return res;
}

//base number and the gcd
pair<long, int> bs(vpi &v, long fac) {
    vpi fq = factorize(fac);
    int gc = -1;
    for (auto&& pr: fq) {
        if (gc == -1)
            gc = pr.y;
        else
            gc = gcd(pr.y, gc);
    }
    long res = 1;
    for (int i = 0; i < fq.size(); ++i) {
        res *= pow(fq[i].x, fq[i].y/gc);
    }
    return {res, gc};
}

        

void perm(vpi& v, int ind, long fac, vector<long>& ks) {
    if (ind == v.size()) {
        ks.pb(fac);
        return;
    }
    long prod = 1;
    for (int i = 0; i <= v[ind].y; ++i) {
        perm(v, ind+1, fac*prod, ks);
        prod *= v[ind].x;
    }
}
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    fio;
    cin >> n;
    ans = 1;
    vpi fq = factorize(n-1);
    for (auto && pr: fq)
        ans *= (pr.y+1);
    ans--;
    if (DEBUG) {
        cerr << ans << " is (no of div of (n-1))-1\n";
    }
    fq = factorize(n);
    if (DEBUG) {
        cerr << "print fq\n";
        for (auto&& x: fq) {
            cerr << x.x << ' ' << x.y << endl; 
        }
    }
    vector<long> ks;
    perm(fq, 0, 1, ks);
    for (const long& k : ks) {
        if (k == 1)
            continue;
        if (DEBUG)
            cerr << "factor " << k << endl;

        //base number
        pair<long,int> nus = bs(fq, k);
        vector<long> pows;
        vpi tv = factorize(nus.y);
        perm(tv, 0, 1, pows);
        long prd;
        for (int po: pows) {
            prd = pow(nus.x, po);
            if ((n/k)%prd == 0)
                continue;
            else if (k == n) {
                if (DEBUG)
                    cerr << "equal case, k = " << prd << endl;
                ans++;
            } else if ((n/k-1)%prd == 0) {
                ans++;
                if (DEBUG)
                    cerr << "chosen k " << prd << endl;
            }
        }
    }

    cout << ans;
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 888