def main():

    def trial_division(n):

        divs = set()

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

            if n % i == 0:

                divs.add(i)

                if i != n//i:

                    divs.add(n//i)

        return divs



    def gcd(x, y):

        if y == 0:

            return x

        while y != 0:

            x, y = y, x % y

        return x



    N = int(eval(input()))

    ans = 0

    divs = trial_division(N) | trial_division(N-1)

    for d in divs:

        if d == 1:

            continue

        num = N

        while num % d == 0 and d <= num:

            num //= d

        if num % d == 1:

            ans += 1



    print(ans)





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))



    def enum_divisors(n):

        # 約数列挙

        divs = []

        for i in range(1, n+1):

            if i*i > n:

                break

            if n % i == 0:

                divs.append(i)

                if n//i != i:

                    # i が平方数でない

                    divs.append(n//i)

        return divs



    ans = 0

    for k in enum_divisors(N-1):

        if 2 <= k:

            ans += 1



    for k in enum_divisors(N):

        if 2 <= k:

            n = N

            while n > 1 and n % k == 0:

                n //= k

            if n % k == 1:

                ans += 1



    print(ans)





if __name__ == '__main__':

    main()

def main():
    def trial_division(n):
        divs = set()
        for i in range(1, int(n**0.5) + 1):
            if n % i == 0:
                divs.add(i)
                if i != n // i:
                    divs.add(n // i)
        return divs

    def gcd(x, y):
        if y == 0:
            return x
        while y != 0:
            x, y = y, x % y
        return x

    N = int(eval(input()))
    ans = 0
    divs = trial_division(N) | trial_division(N - 1)
    for d in divs:
        if d == 1:
            continue
        num = N
        while num % d == 0 and d <= num:
            num //= d
        if num % d == 1:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))

    def enum_divisors(n):
        # 約数列挙
        divs = []
        for i in range(1, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                divs.append(i)
                if n // i != i:
                    # i が平方数でない
                    divs.append(n // i)
        return divs

    ans = 0
    for k in enum_divisors(N - 1):
        if 2 <= k:
            ans += 1
    for k in enum_divisors(N):
        if 2 <= k:
            n = N
            while n > 1 and n % k == 0:
                n //= k
            if n % k == 1:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-    def trial_division(n): -        divs = set() -        for i in range(1, int(n**0.5) + 1): +    N = int(eval(input())) + +    def enum_divisors(n): +        # 約数列挙 +        divs = [] +        for i in range(1, n + 1): +            if i * i > n: +                break -                divs.add(i) -                if i != n // i: -                    divs.add(n // i) +                divs.append(i) +                if n // i != i: +                    # i が平方数でない +                    divs.append(n // i) -    def gcd(x, y): -        if y == 0: -            return x -        while y != 0: -            x, y = y, x % y -        return x - -    N = int(eval(input())) -    divs = trial_division(N) | trial_division(N - 1) -    for d in divs: -        if d == 1: -            continue -        num = N -        while num % d == 0 and d <= num: -            num //= d -        if num % d == 1: +    for k in enum_divisors(N - 1): +        if 2 <= k: +    for k in enum_divisors(N): +        if 2 <= k: +            n = N +            while n > 1 and n % k == 0: +                n //= k +            if n % k == 1: +                ans += 1