def check(i):

	tot=k

	while(tot%i==0):

		tot//=i

	if(tot%i==1):

		setl.add(i)

import math

k=int(eval(input()))

if(k==2):

	print((1))

	exit()

setl = set()

setl.add(k); setl.add(k-1)

for x in range(2,int(math.sqrt(k))+1):

	check(x)

	check(k//x)

print((len(setl)))
def check(i):

	tot=k

	pw=0

	while(tot%i==0):

		tot//=i

		pw+=1

	if(tot%i==1):

		other = tot//i

		if(pw==0 and other>=2 and other<=k):

			setl.add(other)

		setl.add(i)



import math

k=int(eval(input()))

if(k==2):

	print((1))

	exit()

setl = set()

setl.add(k); setl.add(k-1)

for x in range(2,int(math.sqrt(k))+1):

	check(x)

	# check(k//x)

print((len(setl)))
def check(i):
    tot = k
    while tot % i == 0:
        tot //= i
    if tot % i == 1:
        setl.add(i)


import math

k = int(eval(input()))
if k == 2:
    print((1))
    exit()
setl = set()
setl.add(k)
setl.add(k - 1)
for x in range(2, int(math.sqrt(k)) + 1):
    check(x)
    check(k // x)
print((len(setl)))

def check(i):
    tot = k
    pw = 0
    while tot % i == 0:
        tot //= i
        pw += 1
    if tot % i == 1:
        other = tot // i
        if pw == 0 and other >= 2 and other <= k:
            setl.add(other)
        setl.add(i)


import math

k = int(eval(input()))
if k == 2:
    print((1))
    exit()
setl = set()
setl.add(k)
setl.add(k - 1)
for x in range(2, int(math.sqrt(k)) + 1):
    check(x)
    # check(k//x)
print((len(setl)))

+    pw = 0 +        pw += 1 +        other = tot // i +        if pw == 0 and other >= 2 and other <= k: +            setl.add(other) -    check(k // x) +    # check(k//x)