N = int(eval(input()))

originalN = 0 +N

if N == 2:

  print((1))

  exit()

ans = 0

"""

primenum = [2]

count = [0 for _ in range(int(N**0.5)+2)]

for k in range(3, len(count), 2):

  if count[k] == 0:

    primenum.append(k)

    for j in range(k, len(count), k):

      count[j] = 1

    

def factorization(n):

  lis = []

  k = 0

  while primenum[k] <= n:

    if n%primenum[k] == 0:

      c = 0 

      while n%primenum[k] == 0:

        n //= primenum[k]

        c += 1

      lis.append([primenum[k], c])

    else:

      k += 1

      if k > len(primenum)-1:

        break

  if n > 1:

    lis.append([n, 1])

  return lis

"""

def factorization(n):

  lis = []

  if n % 2 == 0:

    c = 0

    while n%2 == 0:

      n //= 2

      c += 1

    lis.append([2, c])

  k = 3

  while k*k <= n:

    if n%k == 0:

      c = 0 

      while n%k == 0:

        n //= k

        c += 1

      lis.append([k, c])

    else:

      k += 2

  if n > 1:

    lis.append([n, 1])

  return lis



list1 = factorization(N-1)

#print(factorization(N-1))

ans1 = 1

for k in range(len(list1)):

  ans1*= list1[k][1]+1

ans1 -= 1

ans += ans1



#print(ans1)



def operation(K):

  N = originalN

  while N%K == 0:

    N //= K

  if N%K == 1:

    return True

  else:

    return False



list2 = factorization(N)

#print(list2)

factorlist = [1]



for l in range(len(list2)):

  list3 = []

  for j in range(list2[l][1]):

    for k in range(len(factorlist)):

      list3.append(factorlist[k]*list2[l][0]**(j+1))

  factorlist += list3



factorlist = factorlist[1:-1]

#print(factorlist)

ans2 = 1

for item in factorlist:

  if operation(item):

    #print(item)

    ans2 +=1





ans += ans2

#print(ans2)



print(ans)
N = int(eval(input()))



if N == 2:

  print((1))

  exit()



ans = 0



def factorization(n):

  lis = []

  if n % 2 == 0:

    c = 0

    while n%2 == 0:

      n //= 2

      c += 1

    lis.append([2, c])

  k = 3

  while k*k <= n:

    if n%k == 0:

      c = 0 

      while n%k == 0:

        n //= k

        c += 1

      lis.append([k, c])

    else:

      k += 2

  if n > 1:

    lis.append([n, 1])

  return lis



list1 = factorization(N-1)

ans1 = 1

for k in range(len(list1)):

  ans1 *= list1[k][1]+1

ans += ans1-1



def operation(K):

  n = N

  while n%K == 0:

    n //= K

  if n%K == 1:

    return True

  else:

    return False



list2 = factorization(N)

factorlist = [1]

for l in range(len(list2)):

  list3 = []

  for j in range(list2[l][1]):

    for k in range(len(factorlist)):

      list3.append(factorlist[k]*list2[l][0]**(j+1))

  factorlist += list3

factorlist = factorlist[1:-1]

ans += 1

for item in factorlist:

  if operation(item):

    ans +=1

print(ans)
N = int(eval(input()))
originalN = 0 + N
if N == 2:
    print((1))
    exit()
ans = 0
"""
primenum = [2]
count = [0 for _ in range(int(N**0.5)+2)]
for k in range(3, len(count), 2):
  if count[k] == 0:
    primenum.append(k)
    for j in range(k, len(count), k):
      count[j] = 1
def factorization(n):
  lis = []
  k = 0
  while primenum[k] <= n:
    if n%primenum[k] == 0:
      c = 0 
      while n%primenum[k] == 0:
        n //= primenum[k]
        c += 1
      lis.append([primenum[k], c])
    else:
      k += 1
      if k > len(primenum)-1:
        break
  if n > 1:
    lis.append([n, 1])
  return lis
"""


def factorization(n):
    lis = []
    if n % 2 == 0:
        c = 0
        while n % 2 == 0:
            n //= 2
            c += 1
        lis.append([2, c])
    k = 3
    while k * k <= n:
        if n % k == 0:
            c = 0
            while n % k == 0:
                n //= k
                c += 1
            lis.append([k, c])
        else:
            k += 2
    if n > 1:
        lis.append([n, 1])
    return lis


list1 = factorization(N - 1)
# print(factorization(N-1))
ans1 = 1
for k in range(len(list1)):
    ans1 *= list1[k][1] + 1
ans1 -= 1
ans += ans1
# print(ans1)
def operation(K):
    N = originalN
    while N % K == 0:
        N //= K
    if N % K == 1:
        return True
    else:
        return False


list2 = factorization(N)
# print(list2)
factorlist = [1]
for l in range(len(list2)):
    list3 = []
    for j in range(list2[l][1]):
        for k in range(len(factorlist)):
            list3.append(factorlist[k] * list2[l][0] ** (j + 1))
    factorlist += list3
factorlist = factorlist[1:-1]
# print(factorlist)
ans2 = 1
for item in factorlist:
    if operation(item):
        # print(item)
        ans2 += 1
ans += ans2
# print(ans2)
print(ans)

N = int(eval(input()))
if N == 2:
    print((1))
    exit()
ans = 0


def factorization(n):
    lis = []
    if n % 2 == 0:
        c = 0
        while n % 2 == 0:
            n //= 2
            c += 1
        lis.append([2, c])
    k = 3
    while k * k <= n:
        if n % k == 0:
            c = 0
            while n % k == 0:
                n //= k
                c += 1
            lis.append([k, c])
        else:
            k += 2
    if n > 1:
        lis.append([n, 1])
    return lis


list1 = factorization(N - 1)
ans1 = 1
for k in range(len(list1)):
    ans1 *= list1[k][1] + 1
ans += ans1 - 1


def operation(K):
    n = N
    while n % K == 0:
        n //= K
    if n % K == 1:
        return True
    else:
        return False


list2 = factorization(N)
factorlist = [1]
for l in range(len(list2)):
    list3 = []
    for j in range(list2[l][1]):
        for k in range(len(factorlist)):
            list3.append(factorlist[k] * list2[l][0] ** (j + 1))
    factorlist += list3
factorlist = factorlist[1:-1]
ans += 1
for item in factorlist:
    if operation(item):
        ans += 1
print(ans)

-originalN = 0 + N -""" -primenum = [2] -count = [0 for _ in range(int(N**0.5)+2)] -for k in range(3, len(count), 2): -  if count[k] == 0: -    primenum.append(k) -    for j in range(k, len(count), k): -      count[j] = 1 -def factorization(n): -  lis = [] -  k = 0 -  while primenum[k] <= n: -    if n%primenum[k] == 0: -      c = 0 -      while n%primenum[k] == 0: -        n //= primenum[k] -        c += 1 -      lis.append([primenum[k], c]) -    else: -      k += 1 -      if k > len(primenum)-1: -        break -  if n > 1: -    lis.append([n, 1]) -  return lis -""" -# print(factorization(N-1)) -ans1 -= 1 -ans += ans1 -# print(ans1) +ans += ans1 - 1 + + -    N = originalN -    while N % K == 0: -        N //= K -    if N % K == 1: +    n = N +    while n % K == 0: +        n //= K +    if n % K == 1: -# print(list2) -# print(factorlist) -ans2 = 1 +ans += 1 -        # print(item) -        ans2 += 1 -ans += ans2 -# print(ans2) +        ans += 1