from math import sqrt

N = int(eval(input()))

ans = 0

divisors = []



for i in range(2, int(sqrt(N))+1):

    if N%i==0:

        divisors.append(i)

        divisors.append(N//i)



for d in set(divisors):

    i = 1

    while N%(d**i)==0:

        i += 1

    n = N//(d**(i-1))

    if n%d==1:

        ans+=1



for i in range(2, int(sqrt(N))+1):

    if (N-1)%i==0:

        if i**2!=N-1:

            ans += 2

        else:

            ans += 1

if N==2:

    print((1))

else:

    print((ans+2))
import sys

def input(): return sys.stdin.readline().strip()

def mapint(): return list(map(int, input().split()))

sys.setrecursionlimit(10**9)



def make_divisors(n):

    lower_divisors , upper_divisors = [], []

    i = 1

    while i*i <= n:

        if n % i == 0:

            lower_divisors.append(i)

            if i != n // i:

                upper_divisors.append(n//i)

        i += 1

    return lower_divisors + upper_divisors[::-1]

 

N = int(eval(input()))

ans = len(make_divisors(N-1))-1

lis = make_divisors(N)

for n in lis:

    G = N

    if n==1:

        continue

    while G%n==0:

        G //= n

    if G%n==1:

        ans += 1

print(ans)
from math import sqrt

N = int(eval(input()))
ans = 0
divisors = []
for i in range(2, int(sqrt(N)) + 1):
    if N % i == 0:
        divisors.append(i)
        divisors.append(N // i)
for d in set(divisors):
    i = 1
    while N % (d**i) == 0:
        i += 1
    n = N // (d ** (i - 1))
    if n % d == 1:
        ans += 1
for i in range(2, int(sqrt(N)) + 1):
    if (N - 1) % i == 0:
        if i**2 != N - 1:
            ans += 2
        else:
            ans += 1
if N == 2:
    print((1))
else:
    print((ans + 2))

import sys


def input():
    return sys.stdin.readline().strip()


def mapint():
    return list(map(int, input().split()))


sys.setrecursionlimit(10**9)


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


N = int(eval(input()))
ans = len(make_divisors(N - 1)) - 1
lis = make_divisors(N)
for n in lis:
    G = N
    if n == 1:
        continue
    while G % n == 0:
        G //= n
    if G % n == 1:
        ans += 1
print(ans)

-from math import sqrt +import sys + + +def input(): +    return sys.stdin.readline().strip() + + +def mapint(): +    return list(map(int, input().split())) + + +sys.setrecursionlimit(10**9) + + +def make_divisors(n): +    lower_divisors, upper_divisors = [], [] +    i = 1 +    while i * i <= n: +        if n % i == 0: +            lower_divisors.append(i) +            if i != n // i: +                upper_divisors.append(n // i) +        i += 1 +    return lower_divisors + upper_divisors[::-1] + -ans = 0 -divisors = [] -for i in range(2, int(sqrt(N)) + 1): -    if N % i == 0: -        divisors.append(i) -        divisors.append(N // i) -for d in set(divisors): -    i = 1 -    while N % (d**i) == 0: -        i += 1 -    n = N // (d ** (i - 1)) -    if n % d == 1: +ans = len(make_divisors(N - 1)) - 1 +lis = make_divisors(N) +for n in lis: +    G = N +    if n == 1: +        continue +    while G % n == 0: +        G //= n +    if G % n == 1: -for i in range(2, int(sqrt(N)) + 1): -    if (N - 1) % i == 0: -        if i**2 != N - 1: -            ans += 2 -        else: -            ans += 1 -if N == 2: -    print((1)) -else: -    print((ans + 2)) +print(ans)