import sys



stdin = sys.stdin



ns = lambda: stdin.readline().rstrip()

ni = lambda: int(stdin.readline().rstrip())

nm = lambda: list(map(int, stdin.readline().split()))

nl = lambda: list(map(int, stdin.readline().split()))



def divisor(n):

    ass = []

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

        if n%i == 0:

            ass.append(i)

            ass.append(n//i)

    return ass



n = ni()

p = divisor(n)

s = set()

for k in p:

    nk = n // k

    for t in divisor(nk - 1):

        s.add(t*k)

ans = 0

s.remove(1)

s.add(n)

for t in s:

    m = n

    while m % t == 0:

        m //= t

    if m % t == 1:

        ans += 1

print(ans)

import sys



stdin = sys.stdin



ns = lambda: stdin.readline().rstrip()

ni = lambda: int(stdin.readline().rstrip())

nm = lambda: list(map(int, stdin.readline().split()))

nl = lambda: list(map(int, stdin.readline().split()))



def divisor(n):

    ass = []

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

        if n%i == 0:

            ass.append(i)

            ass.append(n//i)

    return ass



n = ni()

p = divisor(n)

q = divisor(n-1)

s = set()

ans = 0

for x in p + q:

  m = n

  if x == 1: continue

  while m % x == 0:

    m //= x

  if m % x == 1:

    s.add(x)

print((len(s)))
import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: list(map(int, stdin.readline().split()))
nl = lambda: list(map(int, stdin.readline().split()))


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


n = ni()
p = divisor(n)
s = set()
for k in p:
    nk = n // k
    for t in divisor(nk - 1):
        s.add(t * k)
ans = 0
s.remove(1)
s.add(n)
for t in s:
    m = n
    while m % t == 0:
        m //= t
    if m % t == 1:
        ans += 1
print(ans)

import sys

stdin = sys.stdin
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: list(map(int, stdin.readline().split()))
nl = lambda: list(map(int, stdin.readline().split()))


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


n = ni()
p = divisor(n)
q = divisor(n - 1)
s = set()
ans = 0
for x in p + q:
    m = n
    if x == 1:
        continue
    while m % x == 0:
        m //= x
    if m % x == 1:
        s.add(x)
print((len(s)))

+q = divisor(n - 1) -for k in p: -    nk = n // k -    for t in divisor(nk - 1): -        s.add(t * k) -s.remove(1) -s.add(n) -for t in s: +for x in p + q: -    while m % t == 0: -        m //= t -    if m % t == 1: -        ans += 1 -print(ans) +    if x == 1: +        continue +    while m % x == 0: +        m //= x +    if m % x == 1: +        s.add(x) +print((len(s)))