#!/usr/bin/env python3
import sys

def div(n, k):
    while n % k == 0:
        n //= k
    return n

def solve_slow(N):
    def f():
        ans = 0
        for i in range(2, N+1):
            if div(N, i) % i == 1:
                yield i
    return set(f())

def solve(N: int):
    from itertools import takewhile
    def f():
        for i in takewhile(lambda x: x*x<=N-1, range(1, N)) :
            if (N - 1) % i == 0:
                yield i
                yield (N-1)//i
    def g():
        for i in takewhile(lambda x: x*x<=N, range(2, N)) :
            if N % i == 0:
                if div(N, i) % i == 1:
                    yield i
                if div(N, N // i) % (N // i) == 1:
                    yield N // i
        yield N
    return set(g()) | set(f()) - set([1])

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(len(solve(N)))

def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i),)

if __name__ == '__main__':
    main()
    #test()

ee76d25b2d7ede1b739f5f5e4b3b7aa435f0f6a2
<mask token>


def div(n, k):
    while n % k == 0:
        n //= k
    return n


def solve_slow(N):

    def f():
        ans = 0
        for i in range(2, N + 1):
            if div(N, i) % i == 1:
                yield i
    return set(f())


<mask token>


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    print(len(solve(N)))


def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i))


<mask token>

<mask token>


def div(n, k):
    while n % k == 0:
        n //= k
    return n


def solve_slow(N):

    def f():
        ans = 0
        for i in range(2, N + 1):
            if div(N, i) % i == 1:
                yield i
    return set(f())


def solve(N: int):
    from itertools import takewhile

    def f():
        for i in takewhile(lambda x: x * x <= N - 1, range(1, N)):
            if (N - 1) % i == 0:
                yield i
                yield (N - 1) // i

    def g():
        for i in takewhile(lambda x: x * x <= N, range(2, N)):
            if N % i == 0:
                if div(N, i) % i == 1:
                    yield i
                if div(N, N // i) % (N // i) == 1:
                    yield N // i
        yield N
    return set(g()) | set(f()) - set([1])


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    print(len(solve(N)))


def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i))


<mask token>

<mask token>


def div(n, k):
    while n % k == 0:
        n //= k
    return n


def solve_slow(N):

    def f():
        ans = 0
        for i in range(2, N + 1):
            if div(N, i) % i == 1:
                yield i
    return set(f())


def solve(N: int):
    from itertools import takewhile

    def f():
        for i in takewhile(lambda x: x * x <= N - 1, range(1, N)):
            if (N - 1) % i == 0:
                yield i
                yield (N - 1) // i

    def g():
        for i in takewhile(lambda x: x * x <= N, range(2, N)):
            if N % i == 0:
                if div(N, i) % i == 1:
                    yield i
                if div(N, N // i) % (N // i) == 1:
                    yield N // i
        yield N
    return set(g()) | set(f()) - set([1])


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    print(len(solve(N)))


def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i))


if __name__ == '__main__':
    main()

import sys


def div(n, k):
    while n % k == 0:
        n //= k
    return n


def solve_slow(N):

    def f():
        ans = 0
        for i in range(2, N + 1):
            if div(N, i) % i == 1:
                yield i
    return set(f())


def solve(N: int):
    from itertools import takewhile

    def f():
        for i in takewhile(lambda x: x * x <= N - 1, range(1, N)):
            if (N - 1) % i == 0:
                yield i
                yield (N - 1) // i

    def g():
        for i in takewhile(lambda x: x * x <= N, range(2, N)):
            if N % i == 0:
                if div(N, i) % i == 1:
                    yield i
                if div(N, N // i) % (N // i) == 1:
                    yield N // i
        yield N
    return set(g()) | set(f()) - set([1])


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))
    print(len(solve(N)))


def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i))


if __name__ == '__main__':
    main()

#!/usr/bin/env python3
import sys

def div(n, k):
    while n % k == 0:
        n //= k
    return n

def solve_slow(N):
    def f():
        ans = 0
        for i in range(2, N+1):
            if div(N, i) % i == 1:
                yield i
    return set(f())

def solve(N: int):
    from itertools import takewhile
    def f():
        for i in takewhile(lambda x: x*x<=N-1, range(1, N)) :
            if (N - 1) % i == 0:
                yield i
                yield (N-1)//i
    def g():
        for i in takewhile(lambda x: x*x<=N, range(2, N)) :
            if N % i == 0:
                if div(N, i) % i == 1:
                    yield i
                if div(N, N // i) % (N // i) == 1:
                    yield N // i
        yield N
    return set(g()) | set(f()) - set([1])

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(len(solve(N)))

def test():
    for i in range(2, 1000):
        if solve(i) != solve_slow(i):
            print(i, solve(i), _solve(i),)

if __name__ == '__main__':
    main()
    #test()
