N = int(eval(input()))





def divisor(M):

    div = set()

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

        if M % i == 0:

            div.add(i)

            div.add(M // i)

    return div





def simu(M, X):

    cnt = 0

    while M >= X:

        if M % X == 0:

            M //= X

        elif M % X == 1:

            return True

        else:

            M -= X

        cnt += 1

        if cnt > 1000:

            return False

    return M == 1





A = divisor(N)

B = divisor(N - 1)



# N%K==1となるやつ

ans = len(B) - 1



for a in (A - B):

    if simu(N, a):

        ans += 1



print(ans)

N = int(eval(input()))





def divisor(M):

    div = set()

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

        if M % i == 0:

            div.add(i)

            div.add(M // i)

    return div





def simu(M, X):

    while M % X == 0:

        M //= X

    return M % X == 1





B = divisor(N - 1)

ans = len(B) - 1



A = divisor(N)

A -= {1}

for a in A:

    if simu(N, a):

        ans += 1



print(ans)
N = int(eval(input()))


def divisor(M):
    div = set()
    for i in range(1, int(N**0.5 + 0.5) + 1):
        if M % i == 0:
            div.add(i)
            div.add(M // i)
    return div


def simu(M, X):
    cnt = 0
    while M >= X:
        if M % X == 0:
            M //= X
        elif M % X == 1:
            return True
        else:
            M -= X
        cnt += 1
        if cnt > 1000:
            return False
    return M == 1


A = divisor(N)
B = divisor(N - 1)
# N%K==1となるやつ
ans = len(B) - 1
for a in A - B:
    if simu(N, a):
        ans += 1
print(ans)

N = int(eval(input()))


def divisor(M):
    div = set()
    for i in range(1, int(N**0.5 + 0.5) + 1):
        if M % i == 0:
            div.add(i)
            div.add(M // i)
    return div


def simu(M, X):
    while M % X == 0:
        M //= X
    return M % X == 1


B = divisor(N - 1)
ans = len(B) - 1
A = divisor(N)
A -= {1}
for a in A:
    if simu(N, a):
        ans += 1
print(ans)

-    cnt = 0 -    while M >= X: -        if M % X == 0: -            M //= X -        elif M % X == 1: -            return True -        else: -            M -= X -        cnt += 1 -        if cnt > 1000: -            return False -    return M == 1 +    while M % X == 0: +        M //= X +    return M % X == 1 +B = divisor(N - 1) +ans = len(B) - 1 -B = divisor(N - 1) -# N%K==1となるやつ -ans = len(B) - 1 -for a in A - B: +A -= {1} +for a in A: