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

ll divisor(ll x) {
  ll res=0;
  for (ll i=1; i*i<=x; i++) {
    if (x%i==0) res+=2;
    if (i*i==x) res--;
  }
  return res;
}

int main() {
  ll n; cin>>n;
  ll res=divisor(n-1);
  for (ll i=2; i*i<=n; i++) {
    if (n%i!=0) continue;
    ll nn=n;
    while (nn%i==0) nn/=i;
    if ((nn-1)%i==0) ++res;
  }
  cout<<res<<endl;
}
