n = int(eval(input()))



def yakusu(x):

    xx = 2

    y = []

    while xx**2 < x:

        if x%xx == 0:

            y.append(xx)

            y.append(x//xx)

        xx += 1

    if xx**2 == x:

        y.append(xx)

    y.append(x)

    return y

    

if n == 2:

    ans = 0

else:

    ans = len(yakusu(n-1))



for i in yakusu(n):

    nn = n

    while True:

        if nn%i == 0:

            nn = nn//i

        else:

            break

    if nn%i == 1:

        ans += 1



print(ans)

import math

#import numpy as np

import queue

from collections import deque,defaultdict

import heapq as hpq

from sys import stdin,setrecursionlimit

#from scipy.sparse.csgraph import dijkstra

#from scipy.sparse import csr_matrix

ipt = stdin.readline

setrecursionlimit(10**7)



def main():

    n = int(ipt())

    if n == 2:

        print((1))

        exit()



    def al_div(n):

        pn = 1

        div = []

        while pn**2 < n:

            if n%pn == 0:

                div.append(pn)

                div.append(n//pn)

            pn += 1

        if pn**2 == n:

            div.append(pn)

        return div

    ans = 0

    for i in al_div(n-1):

        if i == 1:

            continue

        else:

            if n%i == 1:

                ans += 1

    for i in al_div(n):

        if i == 1:

            continue

        ni = n

        while ni%i == 0:

            ni //= i

        if ni%i == 1:

            ans += 1



    print(ans)



    return



if __name__ == '__main__':

    main()

n = int(eval(input()))


def yakusu(x):
    xx = 2
    y = []
    while xx**2 < x:
        if x % xx == 0:
            y.append(xx)
            y.append(x // xx)
        xx += 1
    if xx**2 == x:
        y.append(xx)
    y.append(x)
    return y


if n == 2:
    ans = 0
else:
    ans = len(yakusu(n - 1))
for i in yakusu(n):
    nn = n
    while True:
        if nn % i == 0:
            nn = nn // i
        else:
            break
    if nn % i == 1:
        ans += 1
print(ans)

import math

# import numpy as np
import queue
from collections import deque, defaultdict
import heapq as hpq
from sys import stdin, setrecursionlimit

# from scipy.sparse.csgraph import dijkstra
# from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)


def main():
    n = int(ipt())
    if n == 2:
        print((1))
        exit()

    def al_div(n):
        pn = 1
        div = []
        while pn**2 < n:
            if n % pn == 0:
                div.append(pn)
                div.append(n // pn)
            pn += 1
        if pn**2 == n:
            div.append(pn)
        return div

    ans = 0
    for i in al_div(n - 1):
        if i == 1:
            continue
        else:
            if n % i == 1:
                ans += 1
    for i in al_div(n):
        if i == 1:
            continue
        ni = n
        while ni % i == 0:
            ni //= i
        if ni % i == 1:
            ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()

-n = int(eval(input())) +import math + +# import numpy as np +import queue +from collections import deque, defaultdict +import heapq as hpq +from sys import stdin, setrecursionlimit + +# from scipy.sparse.csgraph import dijkstra +# from scipy.sparse import csr_matrix +ipt = stdin.readline +setrecursionlimit(10**7) -def yakusu(x): -    xx = 2 -    y = [] -    while xx**2 < x: -        if x % xx == 0: -            y.append(xx) -            y.append(x // xx) -        xx += 1 -    if xx**2 == x: -        y.append(xx) -    y.append(x) -    return y +def main(): +    n = int(ipt()) +    if n == 2: +        print((1)) +        exit() + +    def al_div(n): +        pn = 1 +        div = [] +        while pn**2 < n: +            if n % pn == 0: +                div.append(pn) +                div.append(n // pn) +            pn += 1 +        if pn**2 == n: +            div.append(pn) +        return div + +    ans = 0 +    for i in al_div(n - 1): +        if i == 1: +            continue +        else: +            if n % i == 1: +                ans += 1 +    for i in al_div(n): +        if i == 1: +            continue +        ni = n +        while ni % i == 0: +            ni //= i +        if ni % i == 1: +            ans += 1 +    print(ans) +    return -if n == 2: -    ans = 0 -else: -    ans = len(yakusu(n - 1)) -for i in yakusu(n): -    nn = n -    while True: -        if nn % i == 0: -            nn = nn // i -        else: -            break -    if nn % i == 1: -        ans += 1 -print(ans) +if __name__ == "__main__": +    main()