import sys

def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    if N == 2: print((1))

    else:

        K = {N, N-1}

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

            if i ** 2 > N: break

            if N % i == 0:

                k = N

                while k % i == 0:

                    k //= i

                if k % i == 1: K |= {i}

            

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

                K |= {i}

                if i ** 2 != N - 1: K |= {(N - 1) // i}

        print((len(K)))

        #print(K)

    return 0



if __name__ == "__main__":

    solve()
import sys



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    ans = {N}

    if N > 2: ans |= {N-1}

    for i in range(2, N): #N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == Nの場合

        if i ** 2 > N: break

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

            ans |= {i}

            if i ** 2 < N - 1:

                ans |= {(N - 1) // i}

        if N % i == 0:

            k = N

            while k % i == 0:

                k //= i

            if k % i == 1: ans |= {i}

            if i ** 2 < N:

                k = N

                while k % i == 0:

                    k //= i

                if k % i == 1: ans |= {i}

    print((len(ans)))

    #print(ans)





    return 0



if __name__ == "__main__":

    solve()
import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    if N == 2:
        print((1))
    else:
        K = {N, N - 1}
        for i in range(2, N + 1):
            if i**2 > N:
                break
            if N % i == 0:
                k = N
                while k % i == 0:
                    k //= i
                if k % i == 1:
                    K |= {i}
            if (N - 1) % i == 0:
                K |= {i}
                if i**2 != N - 1:
                    K |= {(N - 1) // i}
        print((len(K)))
        # print(K)
    return 0


if __name__ == "__main__":
    solve()

import sys


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    ans = {N}
    if N > 2:
        ans |= {N - 1}
    for i in range(2, N):  # N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == Nの場合
        if i**2 > N:
            break
        if (N - 1) % i == 0:
            ans |= {i}
            if i**2 < N - 1:
                ans |= {(N - 1) // i}
        if N % i == 0:
            k = N
            while k % i == 0:
                k //= i
            if k % i == 1:
                ans |= {i}
            if i**2 < N:
                k = N
                while k % i == 0:
                    k //= i
                if k % i == 1:
                    ans |= {i}
    print((len(ans)))
    # print(ans)
    return 0


if __name__ == "__main__":
    solve()

-    if N == 2: -        print((1)) -    else: -        K = {N, N - 1} -        for i in range(2, N + 1): -            if i**2 > N: -                break -            if N % i == 0: +    ans = {N} +    if N > 2: +        ans |= {N - 1} +    for i in range(2, N):  # N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == Nの場合 +        if i**2 > N: +            break +        if (N - 1) % i == 0: +            ans |= {i} +            if i**2 < N - 1: +                ans |= {(N - 1) // i} +        if N % i == 0: +            k = N +            while k % i == 0: +                k //= i +            if k % i == 1: +                ans |= {i} +            if i**2 < N: -                    K |= {i} -            if (N - 1) % i == 0: -                K |= {i} -                if i**2 != N - 1: -                    K |= {(N - 1) // i} -        print((len(K))) -        # print(K) +                    ans |= {i} +    print((len(ans))) +    # print(ans)