#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;
 
 
 int lis( int arr[], int n )  
{  
    int lis[n]; 
   
    lis[0] = 1;    
  
    /* Compute optimized LIS values in bottom up manner */
    for (int i = 1; i < n; i++ )  
    { 
        lis[i] = 1; 
        for (int j = 0; j < i; j++ )   
            if ( arr[i] > arr[j] && lis[i] < lis[j] + 1)  
                lis[i] = lis[j] + 1;  
    } 
  
    // Return maximum value in lis[] 
    return *max_element(lis, lis+n); 
}  
void computeLPSArray(char* pat, int M, int* lps) 
{ 
    // length of the previous longest prefix suffix 
    int len = 0; 
  
    lps[0] = 0; // lps[0] is always 0 
  
    // the loop calculates lps[i] for i = 1 to M-1 
    int i = 1; 
    while (i < M) { 
        if (pat[i] == pat[len]) { 
            len++; 
            lps[i] = len; 
            i++; 
        } 
        else // (pat[i] != pat[len]) 
        { 
            // This is tricky. Consider the example. 
            // AAACAAAA and i = 7. The idea is similar 
            // to search step. 
            if (len != 0) { 
                len = lps[len - 1]; 
  
                // Also, note that we do not increment 
                // i here 
            } 
            else // if (len == 0) 
            { 
                lps[i] = 0; 
                i++; 
            } 
        } 
    } 
} 
string longestCommonPrefix(string ar[], int n) 
{ 
  
    // If size is 0, return empty string 
    if (n == 0) 
        return ""; 
  
    if (n == 1) 
        return ar[0]; 
  
    // Sort the given array 
    sort(ar, ar + n); 
  
    // Find the minimum length from  
    // first and last string 
    int en = min(ar[0].size(),  
                 ar[n - 1].size()); 
  
    // Now the common prefix in first and  
    // last string is the longest common prefix 
    string first = ar[0], last = ar[n - 1]; 
    int i = 0; 
    while (i < en && first[i] == last[i]) 
        i++; 
  
    string pre = first.substr(0, i); 
    return pre; 
} 
bool isvalid(ll int x, ll int y, ll int m, ll int n)
{
    if(x<0||y<0||x>=m||y>=n)return 0;
    else return 1;
}
bool iscor(ll int x, ll int y, ll int m, ll int n)
{
    if(x==0||y==0||x==m-1||y==n-1)return 1;
    else return 0;
}

    
int main()
{
  fastio();
 
ll int T;
//cin>>T;
T=1;
ll int anscount=1,i,n1;
while(T--)
{
 ll int n,count=0;
 cin>>n;if(n==2){cout<<1<<endl;return 0;}
 for(i=2;i*i<=n;i++)
 {
     if(n%i==0)
     {
         n1=n;
         while(n1%i==0)
         {
             n1/=i;
         }
         n1%=i;
         if(n1==1)
         {
             count++;
         }
         if(i!=n/i)
         {
             
         n1=n;
         while(n1%(n/i)==0)
         {
             n1/=n/i;
         }
         n1%=n/i;
         if(n1==1)
         {
             count++;
         }
         }
         
     }
 }
 n--;
 for(i=2;i*i<=n;i++)
 {
     if(n%i==0)
     {
         if(i==n/i)count++;
         else
         count+=2;
     }
 }
 cout<<count+2<<endl;
  
  
  
}
    return 0;
}

Measured memory_bytes: 256