from math import sqrt





def f(x):

    ret = []

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

        if x % i == 0:

            ret.append(i)

            ret.append(x // i)



    return ret





n = int(eval(input()))



ans = 1

for k in range(2, int(sqrt(n)) + 1):

    r = n

    while r % k == 0:

        r //= k



    if r % k == 1:

        ans += 1



li = f(n - 1)

for e in li:

    if e > int(sqrt(n)):

        ans += 1



print(ans)

from math import sqrt





def divisors(x):

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

        if x % i == 0:

            yield i

            if x // i != i:

                yield x // i





n = int(eval(input()))



ans = 0

for e in divisors(n):

    if e == 1:

        continue



    r = n

    while r % e == 0:

        r //= e



    if r % e == 1:

        ans += 1



ans += len(list(divisors(n - 1))) - 1



print(ans)

from math import sqrt


def f(x):
    ret = []
    for i in range(1, int(sqrt(x)) + 1):
        if x % i == 0:
            ret.append(i)
            ret.append(x // i)
    return ret


n = int(eval(input()))
ans = 1
for k in range(2, int(sqrt(n)) + 1):
    r = n
    while r % k == 0:
        r //= k
    if r % k == 1:
        ans += 1
li = f(n - 1)
for e in li:
    if e > int(sqrt(n)):
        ans += 1
print(ans)

from math import sqrt


def divisors(x):
    for i in range(1, int(sqrt(x)) + 1):
        if x % i == 0:
            yield i
            if x // i != i:
                yield x // i


n = int(eval(input()))
ans = 0
for e in divisors(n):
    if e == 1:
        continue
    r = n
    while r % e == 0:
        r //= e
    if r % e == 1:
        ans += 1
ans += len(list(divisors(n - 1))) - 1
print(ans)

-def f(x): -    ret = [] +def divisors(x): -            ret.append(i) -            ret.append(x // i) -    return ret +            yield i +            if x // i != i: +                yield x // i -ans = 1 -for k in range(2, int(sqrt(n)) + 1): +ans = 0 +for e in divisors(n): +    if e == 1: +        continue -    while r % k == 0: -        r //= k -    if r % k == 1: +    while r % e == 0: +        r //= e +    if r % e == 1: -li = f(n - 1) -for e in li: -    if e > int(sqrt(n)): -        ans += 1 +ans += len(list(divisors(n - 1))) - 1