import sys



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def divisors(n):

    lower = []

    upper = []

    for i in range(1, int(n ** 0.5) + 1):

        if n % i == 0:

            lower.append(i)

            if i != n // i:

                upper.append(n // i)



    lower.extend(reversed(upper))

    return lower





def main():

    N = int(readline())



    D = divisors(N)

    D1 = divisors(N - 1)

    ans = len(D1) - 1



    for d in D[1:]:

        n = N

        while n % d == 0:

            n //= d

            if (n - 1) % d == 0:

                ans += 1



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def divisors(n):

    lower = []

    upper = []

    for i in range(1, int(n ** 0.5) + 1):

        if n % i == 0:

            lower.append(i)

            if i != n // i:

                upper.append(n // i)



    lower.extend(reversed(upper))

    return lower





def main():

    N = int(readline())



    D = divisors(N)

    D1 = divisors(N - 1)

    ans = len(D1) - 1



    for d in D[1:]:

        n = N

        while n % d == 0:

            n //= d

        if n % d == 1:

            ans += 1



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def divisors(n):
    lower = []
    upper = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)
    lower.extend(reversed(upper))
    return lower


def main():
    N = int(readline())
    D = divisors(N)
    D1 = divisors(N - 1)
    ans = len(D1) - 1
    for d in D[1:]:
        n = N
        while n % d == 0:
            n //= d
            if (n - 1) % d == 0:
                ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def divisors(n):
    lower = []
    upper = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            lower.append(i)
            if i != n // i:
                upper.append(n // i)
    lower.extend(reversed(upper))
    return lower


def main():
    N = int(readline())
    D = divisors(N)
    D1 = divisors(N - 1)
    ans = len(D1) - 1
    for d in D[1:]:
        n = N
        while n % d == 0:
            n //= d
        if n % d == 1:
            ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()

-            if (n - 1) % d == 0: -                ans += 1 +        if n % d == 1: +            ans += 1