#include<bits/stdc++.h>
#define REG register
using namespace std;
typedef long long ll;

ll n;

ll ans;

inline void Work(){
    scanf("%lld",&n);
    for(REG ll i=2;i*i<n;++i)
        if(!((n-1)%i)) ans+=(i*i==n-1)?1:2;
    for(REG ll i=2;i*i<=n;++i){
        if(n%i) continue;
        ll tmp=n;
        while(!(tmp%i)) tmp/=i;
        if(tmp%i==1) ++ans;
    }
    printf("%lld",ans+2-(n==2));
}

int main(){Work();}