N = int(eval(input()))



divisor = set([N, N - 1])

x = N

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

    z = x

    while z % i == 0:

        z //= i

    if z % i == 1:

        divisor.add(i)

        

    if i == x // i:

        continue

        

    z = x

    while z % (x // i) == 0:

        z //= (x // i)

    if z % (x // i) == 1:

        divisor.add((x // i))

        

x = N - 1

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

    if x % i == 0:

        divisor.add(i)

        divisor.add(x // i)



print((len(divisor) if N > 2 else 1))



N = int(eval(input()))





def calc_divisor(x):

    divisor = []

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

        if x % i == 0:

            if i != 1:

                divisor.append(i)

            if i != x // i:

                divisor.append(x // i)

    return divisor





cand = len(calc_divisor(N - 1))

divisor_n = calc_divisor(N)

for v in divisor_n:

    x = N

    while x % v == 0:

        x //= v



    if x % v == 1:

        cand += 1



print(cand)

N = int(eval(input()))
divisor = set([N, N - 1])
x = N
for i in range(2, int(x**0.5) + 1):
    z = x
    while z % i == 0:
        z //= i
    if z % i == 1:
        divisor.add(i)
    if i == x // i:
        continue
    z = x
    while z % (x // i) == 0:
        z //= x // i
    if z % (x // i) == 1:
        divisor.add((x // i))
x = N - 1
for i in range(2, int(x**0.5) + 1):
    if x % i == 0:
        divisor.add(i)
        divisor.add(x // i)
print((len(divisor) if N > 2 else 1))

N = int(eval(input()))


def calc_divisor(x):
    divisor = []
    for i in range(1, int(x**0.5) + 1):
        if x % i == 0:
            if i != 1:
                divisor.append(i)
            if i != x // i:
                divisor.append(x // i)
    return divisor


cand = len(calc_divisor(N - 1))
divisor_n = calc_divisor(N)
for v in divisor_n:
    x = N
    while x % v == 0:
        x //= v
    if x % v == 1:
        cand += 1
print(cand)

-divisor = set([N, N - 1]) -x = N -for i in range(2, int(x**0.5) + 1): -    z = x -    while z % i == 0: -        z //= i -    if z % i == 1: -        divisor.add(i) -    if i == x // i: -        continue -    z = x -    while z % (x // i) == 0: -        z //= x // i -    if z % (x // i) == 1: -        divisor.add((x // i)) -x = N - 1 -for i in range(2, int(x**0.5) + 1): -    if x % i == 0: -        divisor.add(i) -        divisor.add(x // i) -print((len(divisor) if N > 2 else 1)) + + +def calc_divisor(x): +    divisor = [] +    for i in range(1, int(x**0.5) + 1): +        if x % i == 0: +            if i != 1: +                divisor.append(i) +            if i != x // i: +                divisor.append(x // i) +    return divisor + + +cand = len(calc_divisor(N - 1)) +divisor_n = calc_divisor(N) +for v in divisor_n: +    x = N +    while x % v == 0: +        x //= v +    if x % v == 1: +        cand += 1 +print(cand)