Given is a positive integer N.
We will choose an integer K between 2 and N (inclusive), then we will repeat the operation below until N becomes less than K.
 - Operation: if K divides N, replace N with N/K; otherwise, replace N with N-K.
In how many choices of K will N become 1 in the end?

-----Constraints-----
 - 2 \leq N \leq 10^{12}
 - N is an integer.

-----Input-----
Input is given from Standard Input in the following format:
N

-----Output-----
Print the number of choices of K in which N becomes 1 in the end.

-----Sample Input-----
6

-----Sample Output-----
3

There are three choices of K in which N becomes 1 in the end: 2, 5, and 6.
In each of these choices, N will change as follows:
 - When K=2: 6 \to 3 \to 1
 - When K=5: 6 \to 1
 - When K=6: 6 \to 1

Difficulty: MEDIUM

Solutions:
import math
N = int(input())
if N == 2:
	print(1)
	exit()

def yaku(n):
	a = set()
	s = int(math.sqrt(n))
	for i in range(2, s + 1):
		if n % i == 0:
			a.add(i)
			a.add(n // i)
	return a
ans = len(yaku(N - 1)) + 1
a = yaku(N)
for i in a:
	n = N
	while n % i == 0:
		n = n // i
	if n % i == 1:
		ans += 1
print(ans + 1)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
N = int(input())
A = make_divisors(N)
cnt = 0
for a in A[1:]:
	n = N
	while n % a == 0:
		n = n // a
	if n % a == 1:
		cnt += 1
print(cnt + len(make_divisors(N - 1)) - 1)


n = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
a = make_divisors(n)
b = make_divisors(n - 1)
ans = len(b) - 1
for i in a:
	x = n
	if i == 1:
		continue
	elif i == n:
		ans += 1
	else:
		while x % i == 0:
			x /= i
		if x % i == 1:
			ans += 1
print(ans)


n = int(input())
if n == 2:
	print(1)
	exit()

def ele(n):
	L = [n]
	for i in range(2, int(n ** 0.5) + 1):
		cur = n
		while cur % i == 0:
			cur = cur // i
			L.append(i)
			L.append(n // i)
	L = list(set(L))
	return L
ans = ele(n - 1)
t = ele(n)
for i in range(len(t)):
	temp = n
	while temp % t[i] == 0:
		temp = temp // t[i]
	if temp % t[i] == 1:
		ans.append(t[i])
print(len(ans))


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
N = int(input())
divs = make_divisors(N)
divs2 = make_divisors(N - 1)
ans = len(sorted(divs2)) - 1
for div in divs[1:]:
	tmp = N
	while tmp % div == 0:
		tmp //= div
	if tmp % div == 1:
		ans += 1
print(ans)


def waru(n, k):
	while n >= k:
		if n % k == 0:
			n //= k
		else:
			n %= k
	if n == 1:
		return 1
	else:
		return 0
n = int(input())
p = 0
if n < 100:
	for i in range(2, n + 1):
		p += waru(n, i)
	print(p)
else:
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 1:
			p += 1
		p += waru(n, i)
	if int((n - 1) ** 0.5) ** 2 == n - 1:
		p -= 1
	print(p + 2)


N = int(input())

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
L1 = factorization(N - 1)
s = 1
for [a, b] in L1:
	s *= b + 1

def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
for i in set(make_divisors(N)) - {1}:
	temp = N
	while temp % i == 0:
		temp //= i
	if (temp - 1) % i == 0:
		s += 1
s -= 1
if N == 2:
	print(1)
else:
	print(s)


N = int(input())

def F(n):
	A = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			A.append(i)
			if i != n // i:
				A.append(n // i)
	return A
D = F(N - 1)
E = F(N)
E = sorted(E)
G = []
for i in E[1:]:
	a = N
	while a % i == 0:
		a //= i
	if a % i == 1:
		G.append(i)
print(len(G) + len(D) - 1)


n = int(input())

def divisor(n):
	ret = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ret.append(i)
			if i * i != n:
				ret.append(n // i)
	return ret
a = set(divisor(n - 1))
for k in divisor(n):
	if k < 2:
		continue
	if k in a:
		continue
	m = n
	while m % k == 0:
		m //= k
	s = m % k
	if s == 1:
		a.add(k)
print(len(a) - 1)


n = int(input())
lst = set()
for i in range(2, int(n ** (1 / 2)) + 1):
	k = i
	while k <= n * i:
		k *= i
		if n % k == k // i:
			lst.add(i)
			break
for i in range(2, int(n ** (1 / 2)) + 1):
	if n % i == 1:
		lst.add(i)
		lst.add((n - 1) // i)
if n > 2:
	lst.add(n - 1)
lst.add(n)
print(len(lst))


n = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
import sys
sys.setrecursionlimit(10 ** 7)

def func(N, d):
	if d == 1:
		return False
	while N > 1:
		if N % d == 0:
			N //= d
		elif (N - 1) % d == 0:
			N = 1
		else:
			N = 0
	return True if N == 1 else False
ans = len(set(make_divisors(n - 1))) - 1
l = set(make_divisors(n))
for li in l:
	if func(n, li):
		ans += 1
print(ans)


N = int(input())
import math
a = 0
for i in range(1, int(math.sqrt(N - 1)) + 1):
	if (N - 1) % i == 0:
		a += 2
		i += 1
	else:
		i += 1
a -= 1
if int(math.sqrt(N - 1)) == math.sqrt(N - 1):
	a -= 1
for i in range(2, int(math.sqrt(N)) + 1):
	if N % i == 0:
		t = N
		while t % i == 0:
			t = t / i
		if t % i == 1:
			a += 1
			i += 1
		else:
			i += 1
a += 1
print(a)


def divisor(n):
	x = []
	y = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			x.append(i)
			y.append(n // i)
	if y[-1] == x[-1]:
		y = y[:-1]
	return x + y[::-1]
N = int(input())
a = 0
d = divisor(N)
for K in d:
	if K == 1:
		continue
	n = N
	while n >= K:
		if n % K == 0:
			n //= K
		else:
			n %= K
	if n == 1:
		a += 1
if N - 1 > 1 and N - 1 not in d:
	a += len(divisor(N - 1)) - 1
print(a)


n = int(input())
m = n - 1
a = (n > 2) + 1
for i in range(2, int(n ** 0.5) + 1):
	if m % i < 1:
		a += (m // i > i) + 1
	if n % i < 1:
		o = n
		while o % i < 1:
			o //= i
		a += o % i < 2
print(a)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = len(make_divisors(N - 1)) - 1
ls = make_divisors(N)[1:]
for i in ls:
	n = N
	while n % i == 0:
		n //= i
	if n % i == 1:
		ans += 1
print(ans)


N = int(input())
D = {}
for i in range(2, int(N ** 0.5) + 1):
	n = N
	while n % i == 0 and n != i:
		n //= i
	if n == i or n % i == 1:
		D[i] = 1
N1 = N - 1
for i in range(1, int(N1 ** 0.5) + 1):
	if N1 % i == 0:
		D[i] = 1
		D[N1 // i] = 1
print(len(D))


def check(N, K):
	while N % K == 0:
		N //= K
	return N % K == 1

def divisor(N):
	d = []
	K = 1
	while K * K <= N:
		if N % K == 0:
			d.append(K)
			if K * K != N:
				d.append(N // K)
		K += 1
	return d
N = int(input())
divi = divisor(N)
ans = 0
for x in divi:
	if x > 1:
		ans += int(check(N, x))
ans += len(divisor(N - 1)) - 1
print(ans)


import math
N = int(input())
k = 2
res = 0
ts = set()
kn = {N}
kn_1 = {N - 1}
while k <= math.sqrt(N):
	if N % k == 0:
		nk = N // k
		while nk % k == 0:
			nk //= k
		if nk % k == 1:
			kn.add(k)
		if k % nk == 1:
			kn.add(nk)
		ts.add(k)
		ts.add(nk)
	if (N - 1) % k == 0:
		kn_1.add(k)
		kn_1.add((N - 1) // k)
	k += 1
kn_1 -= {1}
print(len(kn) + len(kn_1))


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7

def resolve():

	def make_divisors(n):
		divisors = []
		for i in range(1, int(pow(n, 0.5)) + 1):
			if n % i == 0:
				divisors.append(i)
				if i != n // i:
					divisors.append(n // i)
		return divisors
	N = int(input())
	div_1 = make_divisors(N)
	res = 0
	for k in div_1:
		if k == 1:
			continue
		n = N
		while n > 1:
			if n % k == 0:
				n //= k
			elif n >= k:
				n %= k
			else:
				n -= k
		if n == 1:
			res += 1
	div_2 = make_divisors(N - 1)
	res += len(div_2) - 1
	print(res)

def __starting_point():
	resolve()
__starting_point()


def makediv(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
n = int(input())
ans = 0
themakedivlist = makediv(n - 1)
for i in themakedivlist:
	if i >= 2:
		ans += 1
k = makediv(n)
k.remove(1)
for i in k:
	tmpn = n
	while True:
		if tmpn == 1:
			ans += 1
			break
		elif tmpn % i == 0:
			tmpn //= i
		elif (tmpn - 1) % i == 0:
			ans += 1
			break
		else:
			break
print(ans)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
a = make_divisors(n)[1:]
ans = 0
for i in a:
	k = n
	while k % i == 0:
		k //= i
	if k % i == 1:
		ans += 1
ans += len(make_divisors(n - 1)) - 1
print(ans)


def divisors(N):
	U = int(N ** 0.5) + 1
	L = [i for i in range(1, U) if N % i == 0]
	return L + [N // i for i in reversed(L) if N != i * i]

def solve(k):
	n = N
	while n % k == 0:
		n //= k
	return n % k == 1
N = int(input())
K = set(divisors(N) + divisors(N - 1)) - {1}
print(sum((solve(k) for k in K)))


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
x = int(input())
ans = 0
di = make_divisors(x)
for i in di:
	if i == 1:
		continue
	p = x
	while p % i == 0:
		p = p // i
	q = x // p
	if p % i == 1 or p == 1:
		ans += 1
d = make_divisors(x - 1)
print(ans + len(d) - 1)


n = int(input())

def factor(n):
	res = set()
	for i in range(2, int(n ** (1 / 2)) + 10):
		if n % i == 0:
			res.add(i)
			res.add(n // i)
	res.add(n)
	res.discard(1)
	return list(res)
ans = 0
ans += len(factor(n - 1))
for k in factor(n):
	n2 = n
	if k == 1:
		continue
	while n2 % k == 0:
		n2 //= k
	if n2 % k == 1:
		ans += 1
print(ans)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = len(make_divisors(N - 1)) - 1

def check(n, x):
	while n % x == 0:
		n //= x
	return n % x == 1
for i in range(2, int(N ** 0.5) + 1):
	if N % i == 0:
		if check(N, i):
			ans += 1
ans += 1
print(ans)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
ans1 = make_divisors(n - 1)
ans2 = make_divisors(n)
for i in ans2:
	if i == 1:
		continue
	n1 = n
	while n1 % i == 0:
		n1 //= i
	if n1 % i == 1:
		ans1.append(i)
ans = list(set(ans1))
print(len(ans) - 1)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = len(make_divisors(N - 1)) - 1
for i in set(make_divisors(N)) - {1}:
	M = N
	while M >= i:
		if M % i == 0:
			M //= i
		else:
			break
	if M % i == 1:
		ans += 1
print(ans)


N = int(input())
if N == 2:
	print(1)
	exit()
if N == 3:
	print(2)
	exit()
ans = []
for n in range(1, int(N ** 0.5) + 1):
	if (N - 1) % n == 0:
		ans.append(n)
		ans.append((N - 1) // n)
for k in range(2, int(N ** 0.5) + 1):
	x = N
	while x % k == 0:
		x //= k
	if 1 in (x % k - k, x % k):
		ans.append(k)
print(len(set(ans)))


import sys

def read_str():
	return sys.stdin.readline().strip()

def read_int():
	return int(sys.stdin.readline().strip())

def read_ints():
	return list(map(int, sys.stdin.readline().strip().split()))

def read_str_split():
	return list(sys.stdin.readline().strip())

def read_int_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def divisors(num):
	lower = []
	upper = []
	for i in range(1, int(num ** 0.5) + 1):
		if num % i == 0:
			lower.append(i)
			if i * i != num:
				lower.append(num // i)
	return lower + upper[::-1]

def Main():
	n = read_int()
	div = divisors(n)[1:]
	ans = len(divisors(n - 1)) - 1
	for x in div:
		num = n
		while num % x == 0:
			num //= x
		if num % x == 1:
			ans += 1
	print(ans)

def __starting_point():
	Main()
__starting_point()


def divisor(N):
	div = []
	for i in range(1, int(N ** 0.5 + 1)):
		if N % i == 0:
			div.append(i)
			if i * i != N:
				div.append(N // i)
	return sorted(div)
N = int(input())
ans = set()
div = divisor(N)
for d in div:
	p = N // d
	while d % p == 0 and p != 1:
		d = d // p
	if (d - 1) % p == 0:
		ans.add(p)
for d in divisor(N - 1):
	ans.add(d)
print(len(ans) - 1 if 1 in ans else len(ans))


def make_divisors(n):
	div = [n]
	for i in range(2, -int(-n ** 0.5 // 1)):
		if n % i == 0:
			div.append(i)
			div.append(n // i)
	if n % n ** 0.5 == 0:
		div.append(int(n ** 0.5))
	div.sort()
	return div
n = int(input())
if n > 2:
	ans = make_divisors(n - 1)
else:
	ans = []
for i in make_divisors(n):
	a = n
	while a % i == 0:
		a = a // i
	if a % i == 1:
		ans.append(i)
print(len(ans))


n = int(input())
ans = 0
for i in range(2, 10 ** 6 + 1):
	m = int(n)
	while True:
		if m % i == 0:
			m //= i
		elif m % i == 1:
			ans += 1
			break
		else:
			break
for i in range(1, 10 ** 6 + 1):
	if (n - 1) % i == 0 and (n - 1) // i > 10 ** 6:
		ans += 1
if n > 10 ** 6:
	ans += 1
print(ans)


n = int(input())
cnt = 0

def check(d):
	tmp = n
	while tmp % d == 0:
		tmp //= d
	tmp %= d
	return tmp == 1
d = 1
while d * d <= n:
	if n % d != 0:
		d += 1
		continue
	if d != 1:
		cnt += check(d)
	if n // d > d:
		cnt += check(n // d)
	d += 1
n -= 1
d = 1
while d * d <= n:
	if n % d != 0:
		d += 1
		continue
	if d != 1:
		cnt += 1
	if n // d > d:
		cnt += 1
	d += 1
print(cnt)


N = int(input())

def cd(n):
	ls = []
	for i in range(1, int(n ** (1 / 2)) + 1):
		if n % i == 0:
			ls += [i, n // i]
	return ls
ans = len(set(cd(N - 1))) - 1
for j in set(cd(N)):
	a = N
	if not j == 1:
		while a % j == 0:
			a //= j
		if a % j == 1:
			ans += 1
print(ans)


n = int(input())
k = 2
count = 1
while k * k <= n:
	m = n
	while m % k == 0:
		m = m / k
	if m % k == 1:
		count += 1
	k += 1
l = 1
while l * l < n - 1:
	if (n - 1) % l == 0:
		count += 1
	l += 1
if n == 2:
	print(1)
else:
	print(count)


n = int(input())
div = []
ans = []
for i in range(1, int(n ** 0.5) + 2):
	if n % i == 0:
		div.append(i)
		div.append(n // i)
for i in div:
	if i == 1:
		continue
	m = n
	while m % i == 0:
		m //= i
	if m % i == 1:
		ans.append(i)
n -= 1
for i in range(1, int(n ** 0.5) + 2):
	if n % i == 0:
		ans.append(i)
		ans.append(n // i)
print(len(set(ans)) - 1)


n = int(input())

def f(x):
	m = int(x ** (1 / 2))
	ret = set()
	for i in range(1, m + 1):
		if x % i == 0:
			ret.add(i)
			ret.add(x // i)
	return ret
ans = set()
for i in f(n):
	if i == 1:
		continue
	g = n
	while g % i == 0:
		g = g // i
	if g % i == 1:
		ans.add(i)
for j in f(n - 1):
	if j == 1:
		continue
	if j in ans:
		continue
	ans.add(j)
print(len(ans))


def make_divs(n):
	divs = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divs.append(i)
			if i != n // i:
				divs.append(n // i)
	return divs
N = int(input())
divs = make_divs(N)
ans = 0
for d in divs:
	if d == 1:
		continue
	N2 = N
	while N2 % d == 0:
		N2 //= d
	if (N2 - 1) % d == 0:
		ans += 1
divs = make_divs(N - 1)
ans += len(divs) - 1
print(ans)


N = int(input().split()[0])

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
Nod = make_divisors(N - 1)
divs = make_divisors(N)
for d in divs:
	c = N
	while True:
		if d == 1:
			break
		if c % d == 1:
			Nod.append(d)
			break
		elif c % d == 0:
			c = c // d
			continue
		else:
			break
print(len(Nod) - 1)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
n = int(input())
div = make_divisors(n)[1:]
s = set(make_divisors(n - 1))
for d in div:
	t = n
	while t % d == 0:
		t //= d
	if (t - 1) % d == 0:
		s.add(d)
print(len(s) - 1)


n = int(input())

def divisor(n):
	fac = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			fac.append(i)
			if i * i != n:
				fac.append(n // i)
	return sorted(fac)
ans = len(divisor(n - 1)) - 1
lst2 = divisor(n)
for i in lst2:
	tmp = n
	if i == 1:
		continue
	while tmp % i == 0:
		tmp //= i
	if tmp % i == 1:
		ans += 1
print(ans)


n = int(input())
if n == 2:
	count = 1
else:
	count = 2
for i in range(2, int(n ** 0.5) + 1):
	if n % i == 0:
		k = n // i
		while k > 0:
			if k % i == 0:
				k = k // i
			else:
				if k % i == 1:
					count += 1
				break
	elif (n - 1) % i == 0:
		count += 1
		if i != (n - 1) // i:
			count += 1
print(count)


def divisors(n):
	ret = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ret.append(i)
			if n // i != i:
				ret.append(n // i)
	return ret
n = int(input())
divs1 = divisors(n)
divs2 = divisors(n - 1)
cnt = len(divs2) - 1
for val in divs1:
	if val == 1:
		continue
	tmp = n
	while tmp % val == 0:
		tmp = tmp // val
	if tmp % val == 1:
		cnt += 1
print(cnt)


def divisor(i):
	s = []
	for j in range(1, int(i ** (1 / 2)) + 1):
		if i % j == 0:
			s.append(i // j)
			s.append(j)
	return sorted(set(s))
n = int(input())
ans = 0
d = divisor(n)
d.pop(0)
for i in d:
	x = n
	while True:
		if not x % i == 0:
			break
		x //= i
	if x % i == 1:
		ans += 1
d = divisor(n - 1)
ans += len(d)
ans -= 1
print(ans)


def calcDivisors(x):
	divs = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			divs.append(i)
			if i * i != x:
				divs.append(x // i)
	return divs
n = int(input())
c = 0
c += len(calcDivisors(n - 1)) - 1
divs = calcDivisors(n)
divs.sort()
for k in divs[1:]:
	r = n
	while r % k == 0:
		r //= k
	if r % k == 1:
		c += 1
print(c)


N = int(input())

def factors(x):
	t = []
	for i in range(2, int(x ** 0.5) + 1):
		if x % i == 0:
			t.append(i)
			if x // i != i:
				t.append(x // i)
	return t
ans = 2 + len(factors(N - 1))
fac = factors(N)
for i in fac:
	n = N
	while n % i == 0:
		n = n // i
	n = n % i
	if n == 1:
		ans += 1
if N == 2:
	print(1)
else:
	print(ans)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
divlist = make_divisors(N)
count = 0
for i in divlist[1:]:
	n = N
	while n % i == 0:
		n = n // i
	if n % i == 1:
		count += 1
print(count + len(make_divisors(N - 1)) - 1)


N = int(input())
C = 0

def ch(k):
	global C
	if k < 2:
		return
	n = N
	while n >= k and n % k == 0:
		n = n // k
	if n % k == 1:
		C += 1
	return
ch(N)
ch(N - 1)
nn = int(N ** 0.5)
for k in range(2, nn + 1):
	z = N % k
	if z <= 1:
		ch(k)
		k2 = N // k
		if k != k2:
			ch(k2)
print(C)


def divisor(n):
	res = []
	i = 1
	while i * i <= n:
		if not n % i:
			res.append(i)
			if i * i != n:
				res.append(n // i)
		i += 1
	return res
N = int(input())
ans = 0
for d in divisor(N):
	if d == 1:
		continue
	n = N
	while not n % d:
		n //= d
	if n % d == 1:
		ans += 1
print(ans + len(divisor(N - 1)) - 1)


n = int(input())

def divisior(n):
	a = []
	i = 1
	while i * i <= n:
		if n % i == 0:
			a.append(i)
			if i * i != n:
				a.append(n // i)
		i += 1
	return a
ans = 0
a = divisior(n)
for x in a[1:]:
	tmp = n
	while tmp % x == 0:
		tmp = tmp // x
	if tmp % x == 1:
		ans += 1
b = divisior(n - 1)
ans = ans + len(b) - 1
print(ans)


N = int(input())

def getDivisors(x):
	anss = set()
	for d in range(1, int(x ** 0.5) + 1):
		if x % d == 0:
			anss.add(d)
			anss.add(x // d)
	return anss
divs = getDivisors(N) | getDivisors(N - 1)
ans = 0
for k in divs:
	if k == 1:
		continue
	x = N
	while x >= k:
		if x % k == 0:
			x //= k
		else:
			x %= k
	if x == 1:
		ans += 1
print(ans)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
l1 = make_divisors(n - 1)
l2 = make_divisors(n)[2:]
for i in l2:
	j = n / i
	while j % i == 0:
		j /= i
	if j % i == 1 and n / i not in l1:
		l1.append(n / i)
print(len(l1))


import sys
n = int(input())
if n == 2:
	print(1)
	sys.exit()
l = [n]
for i in range(2, int(n ** 0.5) + 1):
	if n % i == 0:
		l.append(i)
l = list(set(l))
L = []
for j in range(len(l)):
	x = n
	k = l[j]
	while x % k == 0:
		x = x // k
	if x % k == 1:
		L.append(l[j])
l2 = [n - 1]
for i in range(2, int((n - 1) ** 0.5) + 1):
	if (n - 1) % i == 0:
		l2.append(i)
		l2.append((n - 1) // i)
l2 = list(set(l2))
l2.sort()
print(len(L + l2))


N = int(input())
ans = 0
wnasi = []
for i in range(1, int(pow(N - 1, 0.5)) + 1):
	if (N - 1) % i == 0:
		wnasi.append(i)
		if i != (N - 1) // i:
			wnasi.append((N - 1) // i)
ans += len(wnasi) - 1
wari = []
for i in range(2, int(pow(N, 0.5)) + 1):
	if N % i == 0:
		wari.append(i)
		if i != N // i:
			wari.append(N // i)
for i in wari:
	if i == 1:
		continue
	tmpN = N
	while True:
		if tmpN % i == 0:
			tmpN //= i
		else:
			if tmpN % i == 1:
				ans += 1
			break
print(ans + 1)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
N = int(input())
x = make_divisors(N - 1)[1:]
ans = len(x)
d = make_divisors(N)[1:]
for c in d:
	m = N
	while m % c == 0:
		m //= c
	if m % c == 1:
		ans += 1
print(ans)


import itertools
from collections import deque, defaultdict, Counter
from itertools import accumulate
import bisect
from heapq import heappop, heappush, heapify
import math
from copy import deepcopy
import queue
import numpy as np
Mod = 1000000007

def sieve_of_eratosthenes(n):
	if not isinstance(n, int):
		raise TypeError('n is not int')
	if n < 2:
		raise ValueError('n is not effective')
	prime = [1] * (n + 1)
	for i in range(2, int(math.sqrt(n)) + 1):
		if prime[i] == 1:
			for j in range(2 * i, n + 1):
				if j % i == 0:
					prime[j] = 0
	res = []
	for i in range(2, n + 1):
		if prime[i] == 1:
			res.append(i)
	return res

class UnionFind:

	def __init__(self, n):
		self.parent = [i for i in range(n + 1)]
		self.rank = [0 for i in range(n + 1)]

	def findroot(self, x):
		if x == self.parent[x]:
			return x
		else:
			y = self.parent[x]
			y = self.findroot(self.parent[x])
			return y

	def union(self, x, y):
		px = self.findroot(x)
		py = self.findroot(y)
		if px < py:
			self.parent[y] = px
		else:
			self.parent[px] = py

	def same_group_or_no(self, x, y):
		return self.findroot(x) == self.findroot(y)

def main():

	def divisor(n):
		res = []
		for i in range(1, int(np.sqrt(n)) + 1):
			if n % i == 0:
				res.append(i)
				j = n // i
				if j != i:
					res.append(j)
		res.sort(reverse=True)
		return res[::-1]
	n = int(input())
	div1 = divisor(n - 1)
	div2 = divisor(n)
	ans = len(div1) - 1
	for d in div2:
		if d == 1:
			continue
		nn = n
		while nn % d == 0:
			nn //= d
		if nn % d == 1:
			ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


def divisors(x):
	div = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			div.append(i)
			if x // i != i:
				div.append(x // i)
	return div
n = int(input())
ans = len(divisors(n - 1)) - 1
for k in divisors(n)[1:]:
	t = n
	while t % k == 0:
		t //= k
	if t % k == 1:
		ans += 1
print(ans)


N = int(input())
ans = set()

def check(N, k):
	if k < 2:
		return False
	N //= k
	while N:
		if (N - 1) % k == 0:
			return True
		if N % k:
			return False
		N //= k
	return False
for k in range(1, int(N ** 0.5) + 1):
	if (N - 1) % k == 0:
		(k1, k2) = (k, (N - 1) // k)
		ans.add(k1)
		ans.add(k2)
	if N % k == 0:
		(k1, k2) = (k, N // k)
		if check(N, k1):
			ans.add(k1)
		if check(N, k2):
			ans.add(k2)
ans.remove(1)
print(len(ans))


n = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
d = make_divisors(n)[1:]
l = make_divisors(n - 1)[1:]
ans = 0
for i in d:
	m = n
	while m % i == 0:
		m //= i
	if m % i == 1:
		ans += 1
print(ans + len(l))


def divisors(n):
	small = []
	large = []
	i = 1
	while i * i <= n:
		if not n % i:
			small.append(i)
			large.append(n // i)
		i += 1
	if small[-1] == large[-1]:
		large.pop()
	return small + large[::-1]
n = int(input())
res = set(divisors(n - 1))
res.remove(1)
for d in divisors(n):
	if d == 1:
		continue
	now = n
	while not now % d:
		now //= d
	if now % d == 1:
		res.add(d)
print(len(res))


def divisor(n):
	ans = [n]
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			ans.append(i)
			if i ** 2 < n:
				ans.append(n // i)
		i += 1
	ans.sort()
	return ans
n = int(input())
if n == 2:
	print(1)
	exit()
ans = len(divisor(n - 1))
data = divisor(n)
for k in data:
	m = n
	while m % k == 0:
		m //= k
	if (m - 1) % k == 0:
		ans += 1
print(ans)


def divisors(n):
	ans = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ans.append(i)
			if i != n // i:
				ans.append(n // i)
	return ans
n = int(input())
ans = 0
ans += len(divisors(n - 1)) - 1
for k in divisors(n):
	if k == 1:
		continue
	temp_n = n
	while temp_n % k == 0:
		temp_n /= k
	if temp_n % k == 1:
		ans += 1
print(ans)


def calc_divisor(x):
	divisor = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			divisor.append(i)
			if i != x // i:
				divisor.append(x // i)
	return divisor
N = int(input())
ans = len(calc_divisor(N - 1)) - 1
cand = sorted(calc_divisor(N))[1:]
for k in cand:
	x = N
	while x % k == 0:
		x //= k
	if x % k == 1:
		ans += 1
print(ans)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
a = make_divisors(n)
b = make_divisors(n - 1)
d = list(set(a + b))
ans = 0
for i in list(d):
	if i == 1:
		continue
	x = n
	while x % i == 0:
		x /= i
	if x % i == 1:
		ans += 1
print(ans)


n = int(input())

def divisor(x):
	d = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			d.append(i)
			if i != x // i:
				d.append(x // i)
	return d
ans = len(divisor(n - 1)) - 1
for i in divisor(n):
	if i == 1:
		continue
	n_ = n
	while n_ % i == 0:
		n_ //= i
	if n_ % i == 1:
		ans += 1
print(ans)


import sys

def input():
	return sys.stdin.readline().rstrip()

def main():
	n = int(input())
	ans = 2 - (n == 2)
	for k in range(2, int(n ** 0.5) + 1):
		if n % k == 1:
			ans += 2
			ans -= k ** 2 + 1 == n
		elif n % k == 0:
			g = n // k
			while g % k == 0:
				g = g // k
			ans += g % k == 1
	print(ans)
main()


N = int(input())

def solve(num):
	ret = set()
	p = 1
	while p * p <= num:
		if num % p == 0:
			ret.add(p)
			ret.add(num // p)
		p += 1
	return ret
s1 = solve(N)
s2 = solve(N - 1)
ans = len(s2) - 1
for n in s1:
	if n == 1:
		continue
	tmp = N
	while tmp % n == 0:
		tmp = tmp // n
	if tmp % n == 1:
		ans += 1
print(ans)


import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
mod = 10 ** 9 + 7
INF = 10 ** 18
eps = 10 ** (-7)
N = int(input())

def divisor(n):
	ass = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ass.append(i)
			if i ** 2 == n:
				continue
			ass.append(n // i)
	return ass
ans = len(divisor(N - 1)) - 1
b = divisor(N)
for bi in b:
	if bi == 1:
		continue
	a = N
	while a >= bi:
		if a % bi == 0:
			a = a // bi
		else:
			a = a % bi
	if a == 1:
		ans += 1
print(ans)


def make_divisors(n):
	div = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			div.append(i)
			if i * i != n:
				div.append(n / i)
	return div
N = int(input())
ans = 0
for x in make_divisors(N):
	if x == 1:
		continue
	tmp = N
	while tmp % x == 0:
		tmp /= x
	tmp %= x
	if tmp == 1:
		ans += 1
ans += len(make_divisors(N - 1)) - 1
print(ans)


import sys
input = sys.stdin.readline
from math import sqrt
x = int(input())
DIV = []
for i in range(1, int(sqrt(x)) + 2):
	if x % i == 0:
		DIV.append(i)
		DIV.append(x // i)
ANS = []
for d in DIV:
	if d == 1:
		continue
	k = x
	while k % d == 0:
		k //= d
	if k % d == 1:
		ANS.append(d)
t = x - 1
for i in range(1, int(sqrt(t)) + 2):
	if t % i == 0:
		ANS.append(i)
		ANS.append(t // i)
print(len(set(ANS)) - 1)


def find_divisor(x):
	Divisors = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			Divisors.append(i)
			if i != x // i:
				Divisors.append(x // i)
	return Divisors
n = int(input())
ways = len(find_divisor(n - 1)) - 1
Div = find_divisor(n)
for i in range(1, len(Div)):
	quo = n
	while quo % Div[i] == 0:
		quo = quo // Div[i]
	if quo % Div[i] == 1:
		ways += 1
print(ways)


N = int(input())

def divisor(N):
	ret = []
	for i in range(1, int(N ** 0.5) + 1):
		if N % i == 0:
			ret.append(i)
			if N // i != i:
				ret.append(N // i)
	return ret
div_N = divisor(N)
div_N_1 = divisor(N - 1)
ans = 0
for k in div_N[1:]:
	n = N
	while n % k == 0:
		n //= k
	if n % k == 1:
		ans += 1
ans += len(div_N_1) - 1
print(ans)


import math
n = int(input())
ans = 0
s = set()
s.add(1)
s.add(n)
s.add(n - 1)
for i in range(2, math.ceil(math.sqrt(n)) + 1):
	nn = n
	key = 0
	while nn % i == 0:
		nn = nn // i
		key = 1
	if nn % i == 1:
		s.add(i)
		if key == 0:
			s.add((nn - 1) // i)
s.remove(1)
print(len(s))


def divisors(n):
	x = set()
	m = 1
	while m * m <= n:
		if n % m == 0:
			x.add(m)
			x.add(n // m)
		m += 1
	return x
n = int(input())
d = divisors(n)
ans = 0
for k in d:
	if k == 1:
		continue
	nn = n
	while nn % k == 0:
		nn = nn // k
	ans += nn % k == 1
d1 = divisors(n - 1)
ans += len(d1) - 1
print(ans)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
l1 = make_divisors(N)
ans = len(make_divisors(N - 1)) - 1
for i in l1:
	m = N
	while m % i == 0 and m != 1 and (m != 0) and (i != 1):
		m //= i
	if m % i == 1:
		ans += 1
print(ans)


import math
N = int(input())
if N == 2:
	print(1)
	return
ans = 0
M = int(N ** 0.5) + 1
for k in range(2, M):
	n = N
	while n:
		if n % k == 0:
			n //= k
		elif n % k == 1:
			ans += n != N
			break
		else:
			break

def factorization(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
ans2 = 1
for (_, i) in factorization(N - 1):
	ans2 *= 1 + i
ans += ans2
print(ans)


n = int(input())
div = []
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		div.append(i)
		if i ** 2 != n:
			div.append(n // i)
cnt = 0
for i in range(1, int((n - 1) ** 0.5) + 1):
	if (n - 1) % i == 0:
		if i ** 2 == n - 1:
			cnt += 1
		else:
			cnt += 2
res = cnt - 1
for v in div[1:]:
	tmp = n
	while tmp % v == 0:
		tmp //= v
	if tmp % v == 1:
		res += 1
print(res)


N = int(input())
import math
ans = 0
for i in range(1, int(math.sqrt(N - 1)) + 1):
	if (N - 1) % i == 0:
		ans += 2
		i += 1
	else:
		i += 1
ans -= 1
if int(math.sqrt(N - 1)) == math.sqrt(N - 1):
	ans -= 1
for i in range(2, int(math.sqrt(N)) + 1):
	if N % i == 0:
		temp = N
		while temp % i == 0:
			temp = temp / i
		if temp % i == 1:
			ans += 1
			i += 1
		else:
			i += 1
ans += 1
print(ans)


def divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return sorted(divisors)
n = int(input())
ans = len(divisors(n - 1)) - 1
for k in divisors(n)[1:]:
	boz = n
	while n % k == 0:
		n = n // k
	if n % k == 1:
		ans += 1
	n = boz
print(ans)


def devisor(n):
	cnt = 0
	d = []
	for i in range(1, round(n ** 0.5) + 1):
		if n % i == 0:
			cnt += 1
			d.append(i)
			if n // i != i:
				cnt += 1
				d.append(n // i)
	return (cnt, d)
N = int(input())
ans = devisor(N - 1)[0] - 1
D = devisor(N)[1]
for d in D:
	if d == 1:
		continue
	n = N
	while n % d == 0:
		n = n // d
	if n % d == 1:
		ans += 1
print(ans)


def divisors(n):
	lst = []
	i = 1
	while i * i <= n:
		(q, r) = divmod(n, i)
		if r == 0:
			lst.append(i)
			if i != q:
				lst.append(q)
		i += 1
	return lst
N = int(input())
ans = len(divisors(N - 1)) - 1
divs = divisors(N)
for k in divs:
	if k == 1:
		continue
	temp = N
	while temp % k == 0:
		temp //= k
	if temp % k == 1:
		ans += 1
print(ans)


N = int(input())

def calc_divisor(x):
	divisor = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			if i != 1:
				divisor.append(i)
			if i != x // i:
				divisor.append(x // i)
	return divisor
cand = len(calc_divisor(N - 1))
divisor_n = calc_divisor(N)
for v in divisor_n:
	x = N
	while x % v == 0:
		x //= v
	if x % v == 1:
		cand += 1
print(cand)


n = int(input())
orgn = n
m = n - 1
orgm = m
ncounter = 1
mcounter = 1
for i in range(2, int(m ** 0.5) + 1):
	if m % i == 0:
		tmpc = 1
		m //= i
		while m % i == 0:
			tmpc += 1
			m //= i
		mcounter *= tmpc + 1
if m == orgm and m != 1:
	mcounter += 1
elif m > int(orgm ** 0.5):
	mcounter *= 2
mcounter -= 1
for i in range(2, int(n ** 0.5) + 1):
	if orgn % i == 0:
		n = orgn // i
		while n % i == 0:
			n //= i
		if n % i == 1:
			ncounter += 1
print(ncounter + mcounter)


from math import sqrt
N = int(input())

def f(x):
	n = N
	while n % x == 0:
		n //= x
	return n % x == 1
ans = 1
for k in range(2, int(sqrt(N)) + 1):
	res = N % k
	if res == 0:
		(k1, k2) = (k, N // k)
		ans += 1 if f(k1) else 0
		ans += 1 if k1 != k2 and f(k2) else 0
	elif res == 1:
		ans += 1 if k == (N - 1) // k else 2
if N >= 3:
	ans += 1
print(ans)


n = int(input())
if n == 2:
	print(1)
	return

def get_divisors(num):
	divisors = []
	for d in range(1, num):
		if d * d > num:
			break
		if num % d == 0:
			divisors.append(d)
			if d * d != num:
				divisors.append(int(num // d))
	return divisors
ans = len(get_divisors(n - 1)) - 1
for divisor in get_divisors(n):
	if divisor == 1:
		continue
	temp = n
	while True:
		if temp % divisor != 0:
			break
		temp = temp // divisor
	if temp % divisor == 1:
		ans += 1
print(ans)


import math
import itertools
from collections import deque
from collections import Counter
import bisect
n = int(input())
m = int(pow(n, 0.5))
s = set()
t = set()
for i in range(1, m + 1):
	if n % i == 0:
		s.add(i)
		s.add(n // i)
	if (n - 1) % i == 0:
		t.add(i)
		t.add((n - 1) // i)
ans = len(t) - 1
for i in s:
	if i == 1:
		continue
	c = n
	while True:
		if c % i == 0:
			c = c // i
		else:
			if c % i == 1:
				ans += 1
			break
print(ans)


n = int(input())
if n == 2:
	print(1)
	exit()
nn = n - 1
ans = set([nn])
for i in range(2, int(nn ** 0.5) + 1):
	if nn % i == 0:
		ans.add(i)
		ans.add(nn // i)
l = set()
l.add(n)
for i in range(2, int(n ** 0.5) + 1):
	if n % i == 0:
		l.add(i)
		l.add(n // i)
for j in l:
	m = n
	while m % j == 0:
		m //= j
	if m % j == 1:
		ans.add(j)
print(len(ans))


def main():
	n = int(input())
	count = 2
	sqrt = int(n ** (1 / 2))
	for i in range(2, sqrt + 1):
		if n % i == 1:
			count += 2
		elif n % i == 0:
			ins = n
			while ins % i == 0:
				ins = ins // i
			if ins % i == 1:
				count += 1
	if sqrt ** 2 == n - 1:
		count -= 1
	print(count)
main()


def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
n = int(input())
tmp = n - 1
ret = len(make_divisors(tmp)) - 1
tmplen = make_divisors(n)
for item in tmplen:
	if item == 1:
		continue
	val = n
	while True:
		if val % item == 0:
			val = val // item
		else:
			if val % item == 1:
				ret += 1
			break
print(ret)


n = int(input())

def yakusu(x):
	xx = 2
	y = []
	while xx ** 2 < x:
		if x % xx == 0:
			y.append(xx)
			y.append(x // xx)
		xx += 1
	if xx ** 2 == x:
		y.append(xx)
	y.append(x)
	return y
if n == 2:
	ans = 0
else:
	ans = len(yakusu(n - 1))
for i in yakusu(n):
	nn = n
	while True:
		if nn % i == 0:
			nn = nn // i
		else:
			break
	if nn % i == 1:
		ans += 1
print(ans)


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

def function(n):
	ans = 0
	if n >= 2:
		ans += 1
	for i in range(2, int(n ** 0.5) + 1):
		m = n
		if m % i == 0:
			while m % i == 0:
				m = int(m / i)
			if m % i == 1:
				ans += 1
	ans += divisor(n - 1)
	return ans
n = int(input())
print(function(n))


def divisor(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			if i ** 2 == n:
				continue
			res.append(n // i)
	return res
n = int(input())
res = divisor(n)
ans = len(divisor(n - 1)) - 1
for r in res:
	if r == 1:
		continue
	tmp = n
	while tmp % r == 0:
		tmp //= r
	if tmp % r == 1:
		ans += 1
print(ans)


N = int(input())

def cf(n):
	a = []
	f = 1
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			if n // f != f:
				a.append(n // f)
		f += 1
	return a

def main():
	c = len(cf(N - 1)) - 1
	for f in cf(N):
		t = N
		if f != 1:
			while t % f == 0:
				t //= f
			if t % f == 1:
				c += 1
	print(c)
main()


n = int(input())
set_ans = {n}
for x in range(2, int(n ** 0.5) + 1):
	if n % x == 0:
		tmp = n
		while tmp % x == 0:
			tmp //= x
		if tmp % x == 1:
			set_ans.add(x)
for x in range(1, int((n - 1) ** 0.5) + 1):
	if (n - 1) % x == 0:
		if x > 1:
			set_ans.add(x)
		if (n - 1) // x != x:
			set_ans.add((n - 1) // x)
print(len(set_ans))


def Divisor(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i != 0:
			continue
		res.append(i)
		if i * i != n:
			res.append(n // i)
	return res
n = int(input())
ans = 0
for x in Divisor(n):
	if x == 1:
		continue
	tmp = n
	while tmp % x == 0:
		tmp /= x
	tmp %= x
	if tmp == 1:
		ans += 1
ans += len(Divisor(n - 1)) - 1
print(ans)


def divisor(n):
	div = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			div.append(i)
			if i != n / i:
				div.append(n / i)
	return div
n = int(input())
ans = len(divisor(n - 1)) - 1
for i in divisor(n):
	if i == 1:
		continue
	m = n
	while m % i == 0:
		m /= i
	if m % i == 1:
		ans += 1
print(ans)


N = int(input())

def divisors(n):
	ret1 = []
	ret2 = []
	i = 1
	while i ** 2 <= N:
		if n % i == 0:
			ret1 += [i]
			ret2 += [n // i]
		i += 1
	return ret1 + ret2
ans1 = set(divisors(N - 1))
ans2_cand = set(divisors(N))
ans2 = 0
for k in ans2_cand:
	if k == 1:
		continue
	n = N
	while n % k == 0:
		n = n // k
	if n % k == 1:
		ans2 += 1
print(len(ans1) + ans2 - 1)


def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
N = int(input())
divsN = make_divisors(N)
divsN2 = make_divisors(N - 1)
divsN.pop(0)
ans = len(divsN2) - 1
for div in divsN:
	n = N + 1 - 1
	while True:
		if n % div != 0 or n == 1:
			break
		n //= div
	if n % div == 1:
		ans += 1
print(ans)


def divisors(x):
	div = []
	for i in range(1, x + 1):
		if i * i > x:
			break
		if x % i == 0:
			div.append(i)
			if x % i != i:
				div.append(x // i)
	return div
n = int(input())
ans = set([])
for k in divisors(n):
	if k == 1:
		continue
	N = n
	while N % k == 0:
		N //= k
	N %= k
	if N == 1:
		ans.add(k)
for j in divisors(n - 1):
	if j == 1:
		continue
	ans.add(j)
print(len(ans))


n = int(input())
a = [n]
if n != 2:
	a.append(n - 1)

def div_(N, k):
	while N % k == 0:
		N /= k
	if N % k == 1:
		a.append(k)
for k in range(2, int(n ** 0.5) + 1):
	if n % k == 0:
		div_(n, k)
		if k != n / k:
			div_(n, n // k)
	if (n - 1) % k == 0:
		a.append(k)
		if k != (n - 1) / k:
			a.append((n - 1) // k)
print(len(a))


import numpy as np

def divisors(N):
	return sorted(sum((list({n, N // n}) for n in range(1, int(N ** 0.5) + 1) if not N % n), []))

def prime_factorize_dict(n):
	d = dict()
	while not n & 1:
		d[2] = d.get(2, 0) + 1
		n >>= 1
	f = 3
	while f * f <= n:
		if not n % f:
			d[f] = d.get(f, 0) + 1
			n //= f
		else:
			f += 2
	if n != 1:
		d[n] = d.get(n, 0) + 1
	return d
N = int(input())
count = 0
for n in divisors(N)[1:]:
	M = N
	while not M % n:
		M //= n
	count += M % n == 1
fact_Nm1 = np.array(list(prime_factorize_dict(N - 1).values()), dtype=np.int32)
print(count + np.prod(fact_Nm1 + 1) - 1)


def solve1(n):
	res = []
	for i in range(1, 100):
		u = int(pow(n, 1.0 / i) + 0.1)
		if u ** i == n:
			res.append(u)
	return set(res)

def solve2(n):
	m = n - 1
	i = 1
	res = set()
	while i * i <= m:
		if m % i == 0:
			res.add(i)
			res.add(m / i)
		i += 1
	return res ^ set([1])

def solve3(n):
	i = 2
	res = set()
	while i * i <= n:
		if n % i == 0:
			m = n / i
			while m and m % i == 0:
				m /= i
			if m % i == 1:
				res.add(i)
		i += 1
	return res

def brute_force(n):
	res = []
	for i in range(2, n + 1):
		m = n
		while m % i == 0:
			m /= i
		m %= i
		if m == 1:
			res.append(i)
	return len(res)

def solve(n):
	s1 = solve1(n)
	s2 = solve2(n)
	s3 = solve3(n)
	return len(s1 | s2 | s3)
assert solve(6) == 3
assert solve(3141) == 13
assert solve(314159265358) == 9
assert solve(10 ** 12)
import random
for i in range(2, 100):
	assert brute_force(i) == solve(i)
n = int(input())
print(solve(n))


N = int(input())
if N == 2:
	print(1)
	exit()
DN = {N}
k = 2
while k * k <= N:
	if N % k == 0:
		DN.add(k)
		DN.add(N // k)
	k += 1
DN1 = {N - 1}
k = 2
while k * k <= N - 1:
	if (N - 1) % k == 0:
		DN1.add(k)
		DN1.add((N - 1) // k)
	k += 1
DN1 = len(DN1)
ans = 0
for K in DN:
	tmp = N
	while tmp >= K:
		if tmp % K == 0:
			tmp //= K
		else:
			tmp %= K
	if tmp == 1:
		ans += 1
print(DN1 + ans)


N = int(input())
originalN = 0 + N
if N == 2:
	print(1)
	return
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
ans1 -= 1
ans += ans1

def operation(K):
	N = originalN
	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]
ans2 = 1
for item in factorlist:
	if operation(item):
		ans2 += 1
ans += ans2
print(ans)


def div(x):
	D = set()
	for i in range(1, int(x ** 0.5) + 2):
		if x % i == 0:
			D.add(i)
			D.add(x // i)
	return D
n = int(input())
D0 = div(n)
D1 = div(n - 1)
D0.remove(1)
D1.remove(1)
cnt = 0
for d in D0:
	n_ = n
	while n_ % d == 0:
		n_ = n_ // d
	if n_ % d == 1:
		cnt += 1
cnt += len(D1)
print(cnt)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
ans = len(make_divisors(n - 1)) - 1
for x in make_divisors(n):
	if x == 1:
		continue
	m = n
	while m % x == 0:
		m //= x
	if m % x == 1:
		ans += 1
print(ans)


N = int(input())

def yakusu(N):
	ret = [[], []]
	for i in range(1, int(N ** 0.5) + 1):
		if N % i == 0:
			ret[0].append(i)
			if i ** 2 != N:
				ret[1].append(N // i)
	return ret[0] + ret[1][::-1]
ans = 0
for a in yakusu(N):
	if a == 1:
		continue
	if N % a == 0:
		b = N
		while b % a == 0:
			b //= a
		if (b - 1) % a == 0:
			ans += 1
print(ans + len(yakusu(N - 1)) - 1)


N = int(input())

def make_divisors(n):
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			yield i
			if i != n // i:
				yield (n // i)
ans = len(tuple(make_divisors(N - 1))) - 1
it = make_divisors(N)
next(it)
for k in it:
	tmp = N
	while not tmp % k:
		tmp //= k
	if tmp % k == 1:
		ans += 1
print(ans)


import sys
n = int(input())
if n == 2:
	print(1)
	sys.exit()
divs = []
i = 2
while i * i <= n:
	if n % i == 0:
		divs.append(i)
		if i * i < n:
			divs.append(n // i)
	i += 1
divs.append(n)
ans = set()
i = 2
while i * i <= n - 1:
	if (n - 1) % i == 0:
		ans.add(i)
		if i * i < n - 1:
			ans.add((n - 1) // i)
	i += 1
ans.add(n - 1)
for d in divs:
	tmp = n
	while tmp % d == 0:
		tmp //= d
	if tmp % d == 1:
		ans.add(d)
print(len(ans))


n = int(input())
count = 1
for i in range(int(n ** 0.5)):
	test = i + 1
	n2 = n
	if test == 1:
		continue
	while n2 % test == 0:
		n2 //= test
	else:
		n2 %= test
	if n2 == 1:
		count += 1
n3 = n - 1
a = []
for i in range(1, int(n3 ** 0.5) + 1):
	if n3 % i == 0:
		temp = n3 // i
		if temp > int(n ** 0.5):
			a.append(temp)
count += len(a)
print(count)


N = int(input())
if N == 2:
	print(1)
	exit()
result = 2
for K in range(2, int(N ** 0.5 + 1)):
	t = N
	while t >= K and t % K == 0:
		t //= K
	if t % K == 1:
		result += 1
	if (N - 1) % K == 0 and (N - 1) // K > K:
		result += 1
print(result)


def divisors(N):
	result = {1, N}
	for i in range(2, int(N ** 0.5) + 2):
		if N % i == 0:
			result.add(i)
			result.add(N // i)
	return result
N = int(input().strip())
if N == 2:
	print(1)
else:
	ans = len(divisors(N - 1)) - 1
	for k in divisors(N):
		if k == 1:
			continue
		n = N
		while n % k == 0:
			n = n // k
		if n % k == 1:
			ans += 1
	print(ans)


def factor(N):
	arr = []
	for i in range(1, int(N ** 0.5) + 1):
		if N % i == 0:
			arr.append(i)
			if N // i != i:
				arr.append(N // i)
	return arr
N = int(input())
li = factor(N)
fac = factor(N - 1)
res = len(fac) - 1
for i in range(len(li)):
	if li[i] == 1:
		continue
	tmp = N
	while tmp % li[i] == 0:
		tmp //= li[i]
	if tmp % li[i] == 1:
		res += 1
print(res)


import math

def calc_yakusu_num(n):
	num = 0
	for i in range(1, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				num += 1
			else:
				num += 2
	return num - 1

def calc_yakusu(n):
	yakusu = []
	for i in range(1, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n // i:
				yakusu.append(i)
			else:
				if i != 1:
					yakusu.append(i)
				yakusu.append(n // i)
	return yakusu

def __starting_point():
	ans = 0
	n = int(input())
	ans += calc_yakusu_num(n - 1)
	y = calc_yakusu(n)
	for i in y:
		tmp = n
		while tmp % i == 0:
			tmp //= i
		if tmp % i == 1:
			ans += 1
	print(ans)
__starting_point()


n = int(input())
if n == 2:
	print(1)
	exit()
num = n - 1
cnt = 1
lst = [n]
for i in range(2, int(n ** 0.5) + 1):
	if num % i == 0:
		cnt += 2
		if num == i ** 2:
			cnt -= 1
	if n % i == 0:
		lst.append(i)
		if n != i ** 2:
			lst.append(n // i)
for num in lst:
	n2 = n
	while n2 % num == 0:
		n2 //= num
	if n2 % num == 1:
		cnt += 1
print(cnt)


import queue
N = int(input())

def common_divisors(n):
	i = 1
	res = []
	while i * i <= n:
		if n % i == 0:
			res.append(i)
			res.append(n // i)
		if i * i == n:
			res.pop()
		i += 1
	return res
ans = 0
ans += len(common_divisors(N - 1)) - 1
for i in common_divisors(N):
	if i == 1:
		continue
	n = N
	while n % i == 0:
		n /= i
	if n % i == 1:
		ans += 1
print(ans)


N = int(input())

def D(n):
	A = []
	for i in range(1, int(n ** 0.5) + 1, 1):
		if n % i == 0:
			A.append(i)
			if i != n // i:
				A.append(n // i)
	return A
a = 0
for i in D(N):
	M = N
	if i == 1:
		continue
	else:
		while M % i == 0:
			M = M // i
		if M % i == 1:
			a += 1
print(len(D(N - 1)) - 1 + a)


from math import sqrt, ceil

def factors_set(number):
	factors = set()
	for i in range(1, ceil(sqrt(number)) + 1):
		if number % i == 0:
			factors.add(i)
			factors.add(number // i)
	return factors
N = int(input())
Ks = factors_set(N - 1) | factors_set(N)
Ks.remove(1)
ans = 0
for K in Ks:
	N_tmp = N
	while N_tmp % K == 0:
		N_tmp //= K
	if N_tmp % K == 1:
		ans += 1
print(ans)


n = int(input())
if n == 2:
	print(1)
	exit()
a = [n]
for i in range(2, int(n ** 0.5 + 1)):
	if n % i == 0:
		a.append(i)
		if i != n // i:
			a.append(n // i)
cnt = 0
for v in a:
	s = n
	while v <= s and s % v == 0:
		s = s // v
	if s % v == 1:
		cnt += 1
b = [n - 1]
m = n - 1
for i in range(2, int(m ** 0.5 + 1)):
	if m % i == 0:
		b.append(i)
		if i != m // i:
			b.append(m // i)
print(cnt + len(b))


n = int(input())
n_ = n - 1
a = [n]
if n_ == 1:
	a_ = []
else:
	a_ = [n_]
for i in range(2, int(n ** 0.5 // 1 + 1)):
	if n % i == 0:
		a.append(i)
		if n / i != i:
			a.append(n / i)
	if n_ % i == 0:
		a_.append(i)
		if n_ / i != i:
			a_.append(n_ / i)
ans = len(a_)
for i in a:
	num = n
	while num % i == 0:
		num /= i
	if num % i == 1:
		ans += 1
print(ans)


import copy

def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 2
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1] + [n]

def prime_factorize(n):
	a = []
	while n % 2 == 0:
		a.append(2)
		n //= 2
	f = 3
	while f * f <= n:
		if n % f == 0:
			a.append(f)
			n //= f
		else:
			f += 2
	if n != 1:
		a.append(n)
	return a
n = int(input())
if n == 2:
	print(1)
	return
div1 = make_divisors(n - 1)
cnt = len(div1)
div2 = make_divisors(n)
for i in div2:
	x = copy.deepcopy(n)
	while x >= i:
		if x % i == 0:
			x //= i
		else:
			break
	if x == 1 or x % i == 1:
		cnt += 1
print(cnt)


def check(n, i):
	while n >= i and n % i == 0:
		n //= i
	return n % i == 1

def main():
	N = int(input())
	i = 2
	r = set()
	while i * i <= N:
		if N % i == 0:
			if check(N, i):
				r.add(i)
			if check(N, N // i):
				r.add(N // i)
		elif N % i == 1:
			r.add(i)
			if check(N, N // i):
				r.add(N // i)
		i += 1
	if N > 2:
		r.add(N - 1)
	r.add(N)
	return len(r)
print(main())


n = int(input())
ans = 0
nmcc = 0
i = 1
d = []
while i * i <= n:
	if n % i == 0:
		d.append(i)
		if i * i != n:
			d.append(n // i)
	i += 1
for i in d:
	if i == 1:
		continue
	tmp = n
	while tmp % i == 0:
		tmp //= i
	tmp %= i
	if tmp == 1:
		ans += 1
i = 1
while i * i <= n - 1:
	if (n - 1) % i == 0:
		nmcc += 1
		if i * i != n - 1:
			nmcc += 1
	i += 1
nmcc -= 1
print(ans + nmcc)


import sys
N = int(input())
if N == 2:
	print(1)
	sys.exit(0)
answer_set = set()
for i in range(2, int(N ** 0.5) + 1):
	N2 = N
	while N2 % i == 0:
		N2 //= i
	if N2 % i == 1:
		answer_set.add(i)
for i in range(1, int(N ** 0.5) + 1):
	if (N - 1) % i == 0:
		answer_set.add((N - 1) // i)
answer_set.add(N)
print(len(answer_set))


import math
n = int(input())
ans = 2

def go(n, k):
	aux = 1
	while n % k == 0:
		n /= k
	if n % k == 1:
		return True
	return False
for i in range(2, n):
	if i * i > n:
		break
	if n % i == 0:
		if go(n, i):
			ans += 1
		if i != n / i and go(n, n / i):
			ans += 1
n -= 1
for i in range(2, n):
	if i * i > n:
		break
	if n % i == 0:
		ans += 1
		if i != n / i:
			ans += 1
if n == 1:
	print('1')
else:
	print(ans)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = len(make_divisors(N - 1)) - 1
d = make_divisors(N)
for i in d:
	if i == 1:
		continue
	p = 0
	n = N
	while p == 0:
		n = n // i
		p = n % i
	if p == 1:
		ans += 1
print(ans)


n = int(input())
mod0 = set()
mod1 = set()
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		mod0.add(i)
		mod0.add(n // i)
	if (n - 1) % i == 0:
		mod1.add(i)
		mod1.add((n - 1) // i)
mod0.remove(1)
mod1.remove(1)
ans = 0
for i in mod0:
	nn = n
	while nn % i == 0:
		nn //= i
	if nn % i == 1:
		ans += 1
ans += len(mod1)
print(ans)


N = int(input())

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

def test(n, x):
	while n % x == 0:
		n //= x
	n %= x
	return n == 1
l = make_divisors(N)
la = make_divisors(N - 1)
l.extend(la)
l = set(l)
c = 0
for i in l:
	if i == 1 or i == N:
		continue
	if test(N, i):
		c += 1
print(c + 1)


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [Scanner.string() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [Scanner.int() for i in range(n)]
MOD = 998244353
INF = int(1000000000000000.0)

def divisor(N):
	res = []
	i = 2
	while i * i <= N:
		if N % i == 0:
			res.append(i)
			if i != N // i:
				res.append(N // i)
		i += 1
	if N != 1:
		res.append(N)
	return res

def solve():
	N = Scanner.int()
	d0 = divisor(N - 1)
	ans = len(d0)
	d1 = divisor(N)
	for d in d1:
		X = N
		while X % d == 0:
			X //= d
		if X % d == 1:
			ans += 1
	print(ans)

def main():
	solve()

def __starting_point():
	main()
__starting_point()


import sys

def divisors(n, TF):
	divisors = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if TF == 1:
				if i != n // i:
					divisors.append(n // i)
	return divisors
N = int(input())
if N == 2:
	print(1)
	return
ans = len(divisors(N - 1, 1)) + 2
A = divisors(N, 0)
for i in A:
	x = N
	while x % i == 0:
		x //= i
	if x % i == 1:
		ans += 1
print(ans)


N = int(input())

def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return (lower_divisors + upper_divisors[::-1])[1:]
F = make_divisors(N)
count = 0
for f in F:
	n = N
	while 1:
		if n % f != 0:
			n = n % f
		else:
			n = n // f
		if n < f:
			break
	if n == 1:
		count += 1
print(count + len(make_divisors(N - 1)))


import math
n = int(input())

def s_bunkai(n):
	arr = []
	temp = n
	for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
		if temp % i == 0:
			cnt = 0
			while temp % i == 0:
				cnt += 1
				temp //= i
			arr.append([i, cnt])
	if temp != 1:
		arr.append([temp, 1])
	if arr == []:
		arr.append([n, 1])
	return arr
num = s_bunkai(n - 1)
ans = 1
if num[0][0] != 1:
	ans = 1
	for i in range(len(num)):
		ans *= num[i][1] + 1
for i in range(2, int(math.sqrt(n)) + 1):
	if n % i == 0:
		cnt1 = n
		for j in range(50):
			if cnt1 % i == 0:
				cnt1 //= i
				if cnt1 == 1:
					ans += 1
					break
			else:
				if cnt1 % i == 1:
					ans += 1
				break
print(ans)


N = int(input())

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

def test(N, K):
	if K == 1:
		return False
	while N % K == 0:
		N //= K
	return N % K == 1
cand = divisors(N) + divisors(N - 1)
ans = 0
for d in cand:
	if test(N, d):
		ans += 1
print(ans)


N = int(input())

def divisor(M):
	div = set()
	for i in range(1, int(N ** 0.5 + 0.5) + 1):
		if M % i == 0:
			div.add(i)
			div.add(M // i)
	return div

def simu(M, X):
	while M % X == 0:
		M //= X
	return M % X == 1
B = divisor(N - 1)
ans = len(B) - 1
A = divisor(N)
A -= {1}
for a in A:
	if simu(N, a):
		ans += 1
print(ans)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
N = int(input())
N_div = make_divisors(N)[1:]
N1_div = make_divisors(N - 1)[1:]
ans = len(N1_div)
for i in N_div:
	n = N
	while n % i == 0:
		n //= i
	if n % i == 1:
		ans += 1
print(ans)


N = int(input())
P = 0

def f(x):
	r = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			r.append(i)
			if x != i * i:
				r.append(x // i)
	return r
A = f(N)
M = 0
for i in range(len(A)):
	if A[i] == 1:
		continue
	M = N
	while M % A[i] == 0:
		M //= A[i]
	if M % A[i] == 1:
		P += 1
P += len(f(N - 1)) - 1
print(P)


N = int(input())

def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
A = make_divisors(N - 1)
B = make_divisors(N)
ANS = set(A)
for b in B:
	if b <= 1:
		continue
	wk = N
	while wk % b == 0:
		wk = wk // b
	if wk % b == 1:
		ANS.add(b)
print(len(ANS) - 1)


n = int(input())
div = []
div2 = []
ans = 0
for i in range(1, 10 ** 6 + 1):
	if n % i == 0:
		div += [i, n // i]
	if (n - 1) % i == 0:
		div2 += [i, (n - 1) // i]
div = set(div)
div2 = set(div2)
a = [1]
for i in div:
	if i > 1:
		t = n
		while t:
			if t % i == 0:
				t = t // i
			else:
				if t % i == 1:
					ans += 1
					a += [i]
				break
for i in div2:
	a += [i]
a = set(a)
print(len(a) - 1)


N = int(input())
if N == 2:
	print(1)
	exit()
ans = 2
for K in range(2, N):
	if K * K > N:
		break
	n = N
	if n % K != 0:
		continue
	while n % K == 0:
		n //= K
	if n % K == 1:
		ans += 1
y = 0
N_ = N - 1
for K in range(2, N):
	if K * K >= N_:
		break
	if N_ % K == 0:
		y += 2
if K * K == N_:
	y += 1
print(ans + y)


import copy

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
box = make_divisors(n - 1)
ans = len(box) - 1
boxn = make_divisors(n)
for i in range(1, len(boxn)):
	k = boxn[i]
	nn = copy.deepcopy(n)
	while nn % k == 0 and nn >= k:
		nn = nn // k
	if nn % k == 1:
		ans += 1
print(ans)


init = int(input())
ans = []
for K in range(2, int(init ** 0.5) + 1):
	N = init
	while N % K == 0:
		N /= K
	if N - N // K * K == 1:
		ans.append(K)
tgt = init - 1
cand = []
for i in range(1, int(init ** 0.5) + 1):
	if tgt % i == 0:
		cand.append(i)
		if i != tgt // i:
			cand.append(tgt // i)
ans = list(set(ans + cand))
print(len(ans))


def main():
	n = int(input())

	def get_divisors(num):
		divisors = []
		for i in range(1, int(num ** 0.5) + 1):
			if num % i == 0:
				divisors.extend([i, num // i])
		return set(divisors)
	ans = len(get_divisors(n - 1)) - 1
	for k in get_divisors(n):
		if k == 1:
			continue
		num = n
		while num % k == 0:
			num = num // k
		if num % k == 1:
			ans += 1
	print(ans)
main()


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(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)
print(len(setl))


def rest(n, i):
	while n % i == 0:
		n //= i
	return n
N = int(input())
if N == 2:
	print(1)
	exit()
ans = [N - 1, N]
for i in range(2, int(N ** 0.5) + 1):
	if (N - 1) % i == 0:
		ans.append(i)
		ans.append((N - 1) // i)
	elif N % i == 0:
		if rest(N, i) % i == 1 or rest(N, N // i) % (N // i) == 1:
			ans.append(i)
print(len(set(ans)))


def divisors(n):
	ret = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ret.append(i)
			if n // i != i:
				ret.append(n // i)
	return ret
n = int(input())
ans = len(divisors(n - 1)) - 1
for d in divisors(n)[1:]:
	tmp = n
	while tmp % d == 0:
		tmp = tmp // d
	if tmp % d == 1:
		ans += 1
print(ans)


N = int(input())

def f(N, i):
	if i == 1:
		return False
	while N % i == 0:
		N //= i
	if N % i == 1:
		return True
	else:
		return False
ans = 0
i = 1
while i <= N ** 0.5:
	if N % i > 0:
		i += 1
		continue
	if f(N, i):
		ans += 1
	if i % (N // i) == 1:
		ans += 1
	i += 1
i = 1
while i <= (N - 1) ** 0.5:
	if (N - 1) % i > 0:
		i += 1
		continue
	if N % i == 1 and N // i != i:
		ans += 1
	if N % ((N - 1) // i) == 1:
		ans += 1
	i += 1
print(ans)


N = int(input())

def divisor(n):
	if n == 1:
		return []
	ret = [n]
	for i in range(2, n + 1):
		if i * i == n:
			ret.append(i)
		elif i * i > n:
			break
		elif n % i == 0:
			ret.append(i)
			ret.append(n // i)
	ret.sort()
	return ret
ans = len(divisor(N - 1))
for k in divisor(N):
	M = N
	while M % k == 0:
		M //= k
	if M % k == 1:
		ans += 1
print(ans)


from math import sqrt
n = int(input())
ans = 0
for i in range(2, int(sqrt(n)) + 1):
	if n % i == 0:
		x = i
		y = n // i
		while y % x == 0:
			y //= x
		if (y - 1) % x == 0:
			ans += 1
	elif (n - 1) % i == 0:
		if i ** 2 == n - 1:
			ans += 1
		else:
			ans += 2
if n > 2:
	ans += 2
else:
	ans += 1
print(ans)


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

def all_pattern(l):
	global n
	ans = 0
	for ds in make_divisors(l)[1:]:
		k = n
		while k % ds == 0:
			k //= ds
		ans += k % ds == 1
	return ans
n = int(input())
print(all_pattern(n) + all_pattern(n - 1))


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

	def divisor_set(x):
		ret = set()
		if x > 1:
			ret.add(x)
		d = 2
		while d * d <= x:
			if x % d == 0:
				ret.add(d)
				ret.add(x // d)
			d += 1
		return ret
	ans = 0
	ans += len(divisor_set(N - 1))
	for k in divisor_set(N):
		x = N
		while x % k == 0:
			x //= k
		if x % k == 1:
			ans += 1
	print(ans)

def __starting_point():
	main()
__starting_point()


n = int(input())
m = n - 1
c = 2 if n > 2 else 1
for i in range(2, int(m ** 0.5) + 1):
	if m % i == 0:
		c += 1
		if m // i != i:
			c += 1
for i in range(2, int(n ** 0.5) + 1):
	if n % i == 0:
		j = n // i
		while j % i == 0:
			j //= i
		if j % i <= 1:
			c += 1
print(c)


def resolve():

	def make_divisors(n):
		divisors = []
		for i in range(1, int(n ** 0.5) + 1):
			if n % i == 0:
				divisors += [i, n // i]
		divisors.sort()
		return divisors
	N = int(input())
	ans = 0
	div1 = set(make_divisors(N - 1))
	ans += len(div1) - 1
	div2 = set(make_divisors(N))
	for k in div2:
		if k == 1:
			continue
		n = N
		while n % k == 0:
			n //= k
		if n % k == 1:
			ans += 1
	print(ans)

def __starting_point():
	resolve()
__starting_point()


n = int(input())
m = n - 1
i = 2
ans = 1
while i * i <= m:
	if m % i == 0:
		num = 1
		while m % i == 0:
			num += 1
			m //= i
		ans *= num
	i = i + 1
if m != 1:
	ans *= 2
ans -= 1
m = n
import numpy as np
i = 2
factor = []
while i * i <= n:
	if n % i == 0:
		l = []
		num = 1
		l.append(num)
		while n % i == 0:
			num *= i
			l.append(num)
			n //= i
		factor.append(np.array(l))
	i = i + 1
if n > 1:
	factor.append(np.array([1, n]))
divisor = factor[-1]
for i in range(len(factor) - 1):
	divisor = np.outer(divisor, factor[i])
divisor = np.outer(np.array(1), divisor)
for i in divisor[0]:
	if i == 1:
		continue
	n = m
	while n % i == 0:
		n //= i
	if n % i == 1:
		ans += 1
print(ans)


import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
sys.setrecursionlimit(100000000)

def input():
	return sys.stdin.readline().rstrip()
N = int(input())

def f(x):
	ans = set()
	i = 1
	while i * i <= x:
		if x % i == 0:
			ans.add(i)
		i += 1
	for i in ans.copy():
		ans.add(x // i)
	return ans
ans = set()
for K in f(N) | f(N - 1):
	if K == 1:
		continue
	n = N
	while n % K == 0:
		n //= K
	if n % K == 1:
		ans.add(K)
print(len(ans))


import sys
sr = lambda : sys.stdin.readline().rstrip()
ir = lambda : int(sr())
lr = lambda : list(map(int, sr().split()))
N = ir()
answer = 0

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors[1:]
cand = make_divisors(N) + make_divisors(N - 1)
for x in cand:
	M = N
	while M % x == 0:
		M //= x
	r = M % x
	if r == 1:
		answer += 1
print(answer)


def div(x):
	D = set()
	d = 1
	while d * d <= x:
		if x % d == 0:
			D.add(d)
			D.add(x // d)
		d += 1
	return D
n = int(input())
cnt = 0
for d in div(n) | div(n - 1):
	if d == 1:
		continue
	tmp = n
	while tmp % d == 0:
		tmp = tmp // d
	if tmp % d == 1:
		cnt += 1
print(cnt)


N = int(input())

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

def calc(n, k):
	if n % k == 0:
		return calc(n // k, k)
	elif n < k:
		return n
	else:
		return calc(n % k, k)
ans = make_devision(N - 1)
for i in make_devision(N):
	if i == 1:
		continue
	if calc(N, i) == 1:
		ans.append(i)
print(len(ans) - 1)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
L = len(make_divisors(N))
A = make_divisors(N)
ans = 0
for i in range(1, L):
	t = N
	while t % A[i] == 0:
		t = t // A[i]
	if t % A[i] == 1:
		ans = ans + 1
print(ans + len(make_divisors(N - 1)) - 1)


def decomposition(x):
	ret = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			ret.append(i)
			if x // i != i:
				ret.append(x // i)
	return sorted(ret)
n = int(input())
s = decomposition(n)
t = decomposition(n - 1)
ans = 0
for num in s:
	if num == 1:
		continue
	tmp = n
	while tmp % num == 0:
		tmp = tmp // num
	if tmp % num == 1:
		ans += 1
print(ans + len(t) - 1)


from math import sqrt, ceil

def divisors(n):
	out = []
	nn = ceil(sqrt(n))
	for i in range(1, nn):
		if n % i == 0:
			out.append(i)
			out.append(n // i)
	if nn ** 2 == n:
		out.append(nn)
	out.sort()
	return out
n = int(input())
a = len(divisors(n - 1)[1:])
d = divisors(n)
for dd in d[1:]:
	nn = n
	while nn % dd == 0:
		nn = nn // dd
	if nn % dd == 1:
		a += 1
print(a)


from math import sqrt

def f(x):
	ret = []
	for i in range(1, int(sqrt(x)) + 1):
		if x % i == 0:
			ret.append(i)
			ret.append(x // i)
	return ret
n = int(input())
ans = 1
for k in range(2, int(sqrt(n)) + 1):
	r = n
	while r % k == 0:
		r //= k
	if r % k == 1:
		ans += 1
li = f(n - 1)
for e in li:
	if e > int(sqrt(n)):
		ans += 1
print(ans)


def divisors(n):
	ret = set()
	for i in range(1, int(n ** 0.5) + 2):
		if n % i == 0:
			ret.add(i)
			ret.add(n // i)
	ret.remove(1)
	return ret

def main():
	N = int(input())
	s = divisors(N)
	ans = divisors(N - 1)
	for x in s:
		n = N
		if x == 1:
			continue
		while n % x == 0:
			n = n // x
		if n % x == 1:
			ans.add(x)
	print(len(ans))
main()


N = int(input())
n = N
ans = 0

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
l = make_divisors(N - 1)
r = make_divisors(N)
ans = len(l) - 1
for i in range(len(r)):
	N = n
	K = r[i]
	if K == 1:
		continue
	while N % K == 0:
		N = N // K
	if N % K == 1:
		ans += 1
print(ans)


def f(x):
	s = set()
	for i in range(1, int(x ** 0.5) + 6):
		if x % i == 0:
			s.add(i)
			s.add(x // i)
	return s
ans = set()
n = int(input())
ans = f(n - 1)
ans1 = f(n)
ans1.remove(1)
for x in ans1:
	p = n
	while p >= x:
		if p % x == 0:
			p //= x
		else:
			p %= x
	if p == 1:
		ans.add(x)
if 1 in ans:
	ans.remove(1)
print(len(ans))


import math
n = int(input())
cnt = 0
for i in range(2, int(math.sqrt(n)) + 1):
	if (n - 1) % i == 0:
		cnt = cnt + 2
	if n % i == 0:
		s = n
		while s % i == 0:
			s = s // i
		if s % i == 1:
			cnt = cnt + 1
if int(math.sqrt(n - 1)) == math.sqrt(n - 1):
	cnt = cnt - 1
if n == 2:
	print(1)
else:
	print(cnt + 2)


N = int(input())

def solve(n):
	i = 1
	ret = set()
	while i * i <= n:
		if n % i == 0:
			ret.add(i)
			ret.add(n // i)
		i += 1
	return ret
div_N_sub_1 = solve(N - 1)
div_N = solve(N)
ans = len(div_N_sub_1) - 1
for i in div_N:
	if i == 1:
		continue
	tmp = N
	while tmp % i == 0:
		tmp //= i
	if tmp % i == 1:
		ans += 1
print(ans)


from math import sqrt

def divisors(x):
	for i in range(1, int(sqrt(x)) + 1):
		if x % i == 0:
			yield i
			if x // i != i:
				yield (x // i)
n = int(input())
ans = 0
for e in divisors(n):
	if e == 1:
		continue
	r = n
	while r % e == 0:
		r //= e
	if r % e == 1:
		ans += 1
ans += len(list(divisors(n - 1))) - 1
print(ans)


import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
n = int(input())
ans = 0

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ndivs = make_divisors(n)
n1divs = make_divisors(n - 1)
ans += len(n1divs) - 1
for i in range(1, len(ndivs)):
	tmp = n
	k = ndivs[i]
	while tmp % k == 0:
		tmp //= k
	if tmp % k == 1:
		ans += 1
print(ans)


n = int(input())
divisors = set()
for i in range(1, int(-(-n ** 0.5 // 1)) + 1):
	if n % i == 0:
		divisors |= {i, n // i}
ans = set()
for div in divisors:
	x = n
	if div == 1:
		continue
	while x % div == 0:
		x = x // div
	if x % div == 1:
		ans |= {div}
n -= 1
for i in range(1, int(-(-n ** 0.5 // 1)) + 1):
	if n % i == 0:
		ans |= {i, n // i}
ans ^= {1}
print(len(ans))


n = int(input())
k = 2
count = set()
while k * k <= n:
	if n % k == 1:
		count.add(k)
		count.add((n - 1) // k)
	elif n % k == 0:
		n_copy = n
		while n_copy % k == 0:
			n_copy //= k
		if n_copy % k == 1:
			count.add(k)
	k += 1
if n > 2:
	count.add(n - 1)
count.add(n)
print(len(count))


def m(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
n = int(input())
ans = len(m(n - 1)) - 1
A = m(n)
for i in range(1, len(A)):
	s = n
	while s % A[i] == 0:
		s = s // A[i]
	if s % A[i] == 1:
		ans = ans + 1
print(ans)


from sys import stdin
nii = lambda : map(int, stdin.readline().split())
lnii = lambda : list(map(int, stdin.readline().split()))
n = int(input())

def divisore(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
ans_l = divisore(n - 1)[1:]
d = divisore(n)
for i in d[1:]:
	nn = n
	while nn % i == 0:
		nn //= i
	if nn % i == 1:
		ans_l.append(i)
print(len(ans_l))


def f(n):
	d = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i < 1:
			d += (i,)
			if i != n // i:
				d += (n // i,)
	return d[1:]
n = int(input())
a = f(n - 1)
for i in f(n):
	m = n
	while m % i < 1:
		m //= i
	if m % i < 2:
		a += (i,)
print(len(set(a)))


nn = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = len(make_divisors(nn - 1)) - 1
lis = make_divisors(nn)
del lis[0]
for i in lis:
	t = nn
	while t % i == 0 and t != 0:
		t = t // i
	if t % i == 1:
		ans += 1
print(ans)


import math

def prime(x):
	L = []
	last = math.floor(x ** 0.5)
	for i in range(1, last + 1):
		if x % i == 0:
			L.append(i)
			if x // i != i:
				L.append(x // i)
	return L
N = int(input())
if N == 2:
	print(1)
	exit()
L = prime(N - 1)
ans = len(L) - 1
D = prime(N)
for i in D:
	if i == 1:
		continue
	t = N
	while t / i == t // i:
		t //= i
	t -= 1
	if t / i == t // i:
		ans += 1
print(ans)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
a = make_divisors(n - 1)
ans = len(a) - 1
b = make_divisors(n)[1:]
c = []
for num in b:
	d = n
	while d % num == 0:
		d = d / num
	if d % num == 1:
		c.append(num)
ans += len(c)
print(ans)


def div(n):
	r = int(n ** (1 / 2))
	for i in range(1, r + 1):
		if n % i == 0:
			yield i
			if i * i != n:
				yield (n // i)
n = int(input())
count = len(list(div(n - 1))) - 1
for i in div(n):
	if i > 1:
		x = n
		while x % i == 0:
			x //= i
		if x % i == 1:
			count += 1
print(count)


def check(i):
	tot = k
	while tot % i == 0:
		tot //= i
	if tot % i == 1:
		setl.add(i)
import math
k = int(input())
setl = set()
setl.add(k)
setl.add(k - 1)
for x in range(2, int(math.sqrt(k)) + 1):
	check(x)
	check(k // x)
if setl.__contains__(1):
	setl.remove(1)
print(len(setl))


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
N = int(input())
ans = make_divisors(N - 1)[1:]
n_div = make_divisors(N)[1:]
for d in n_div:
	n = N
	while n % d == 0:
		n //= d
	if n % d == 1:
		ans.append(d)
print(len(ans))


def enumDivisor(n):
	ans = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			ans.append(i)
			if i * i != n:
				ans.append(n // i)
	return ans
n = int(input())
ans = 0
for k in enumDivisor(n):
	if k == 1:
		continue
	tmp = n
	while tmp % k == 0:
		tmp //= k
	tmp %= k
	if tmp == 1:
		ans += 1
ans += len(enumDivisor(n - 1)) - 1
print(ans)


n = int(input())

def y(n):
	yaku = set()
	for i in range(1, 10 ** 6 + 1):
		if n % i == 0:
			yaku.add(i)
			yaku.add(n // i)
	yaku.remove(1)
	return yaku
ans = len(y(n - 1))
for i in y(n):
	nn = n
	while nn % i == 0:
		nn //= i
	if nn % i == 1:
		ans += 1
print(ans)


import sys
import math
import collections
import bisect
import itertools
import fractions
import copy
import decimal
import queue
sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
ni = lambda : int(sys.stdin.readline())
ns = lambda : list(map(int, sys.stdin.readline().split()))
na = lambda : list(map(int, sys.stdin.readline().split()))

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

def main():
	n = ni()
	ans = set()
	ans.add(n)
	for i in range(2, int(n ** 0.5) + 1):
		tmp = n
		while tmp % i == 0:
			tmp //= i
		if (tmp - 1) % i == 0:
			ans.add(i)
	yaku = set(make_divisors(n - 1))
	ans = ans | yaku
	print(len(ans))

def __starting_point():
	main()
__starting_point()


import sys
sys.setrecursionlimit(2000)

def joken(a, n):
	if n == 1:
		return 0
	elif a % n == 0 and a // n >= n:
		return joken(a // n, n)
	elif a % n == 1:
		return 1
	elif a % n == 0 and a // n == 1:
		return 1
	else:
		return 0

def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
N = int(input())
c = len(make_divisors(N - 1))
d = make_divisors(N)
a = 0
for i in range(len(d)):
	a += joken(N, d[i])
print(a + c - 1)


n = int(input())
ans = set()
ans.add(n)
i = 2
x = 1
while x * x <= n - 1:
	if (n - 1) % x == 0:
		ans.add(x)
		ans.add((n - 1) // x)
	x += 1
while i * i <= n:
	t = n
	while t % i == 0:
		t /= i
	if t % i == 1:
		ans.add(i)
	i += 1
print(len(ans) - 1)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
n = int(input())
cnt = len(make_divisors(n - 1)) - 1
lst = make_divisors(n)
for k in lst:
	if k != 1:
		t = n
		while t % k == 0:
			t //= k
		if (t - 1) % k == 0:
			cnt += 1
print(cnt)


import sys

def solve():
	input = sys.stdin.readline
	N = int(input())
	ans = {N}
	if N > 2:
		ans |= {N - 1}
	for i in range(2, N):
		if i ** 2 > N:
			break
		if (N - 1) % i == 0:
			ans |= {i}
			if i ** 2 < N - 1:
				ans |= {(N - 1) // i}
		if N % i == 0:
			k = N
			while k % i == 0:
				k //= i
			if k % i == 1:
				ans |= {i}
			if i ** 2 < N:
				k = N
				while k % i == 0:
					k //= i
				if k % i == 1:
					ans |= {i}
	print(len(ans))
	return 0

def __starting_point():
	solve()
__starting_point()


n = int(input())
c = 0
for i in range(2, int(n ** 0.5) + 1):
	d = n
	while d % i == 0:
		d //= i
	if n % i == 0 and (d - 1) % i == 0:
		c += 1
for i in range(2, int((n - 1) ** 0.5) + 1):
	if (n - 1) % i == 0:
		if n - 1 == i ** 2:
			c += 1
		else:
			c += 2
if n < 3:
	print(1)
else:
	print(c + 2)


def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors[1:]
n = int(input())
a = make_divisors(n - 1)
b = make_divisors(n)
count = 0
for kk in b:
	mom = n
	while mom % kk == 0:
		mom //= kk
	if mom % kk == 1:
		count += 1
print(len(a) + count)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import time, random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

class Prime:

	def __init__(self, n):
		self.M = m = int(math.sqrt(n)) + 10
		self.A = a = [True] * m
		a[0] = a[1] = False
		self.T = t = [2]
		for j in range(4, m, 2):
			a[j] = False
		for i in range(3, m, 2):
			if not a[i]:
				continue
			t.append(i)
			for j in range(i * i, m, i):
				a[j] = False
		self.ds_memo = {}
		self.ds_memo[1] = set([1])

	def is_prime(self, n):
		return self.A[n]

	def division(self, n):
		d = collections.defaultdict(int)
		for c in self.T:
			while n % c == 0:
				d[c] += 1
				n //= c
			if n < 2:
				break
		if n > 1:
			d[n] += 1
		return d.items()

	def divisions(self, n):
		if n in self.ds_memo:
			return self.ds_memo[n]
		for c in self.T:
			if n % c == 0:
				rs = set([c])
				for cc in self.divisions(n // c):
					rs.add(cc)
					rs.add(cc * c)
				self.ds_memo[n] = rs
				return rs
		rs = set([n])
		self.ds_memo[n] = rs
		return rs

def main():
	n = I()
	pr = Prime(10 ** 12)
	d = list(pr.division(n))
	r = 0
	l = len(d)
	for i in range(1, 2 ** l):
		t = [d[j] for j in range(l) if 2 ** j & i]
		m = min(map(lambda x: x[1], t))
		ok = True
		for (k, v) in t:
			if v % m > 0:
				ok = False
				break
		if not ok:
			continue
		for j in range(1, m + 1):
			if m % j > 0:
				continue
			mk = m // j
			u = 1
			for (k, v) in t:
				u *= k ** (v // m * mk)
			nn = n
			while nn % u == 0:
				nn //= u
			if nn % u == 1:
				r += 1
	d = pr.division(n - 1)
	k = 1
	for (_, v) in d:
		k *= v + 1
	r += k - 1
	return r
print(main())


N = int(input())
k = 2
ans = 1
factors = []
i = 1
while i * i < N - 1:
	if (N - 1) % i == 0:
		ans += 1
	i += 1
while k * k <= N:
	n = 0
	while pow(k, n) <= N:
		if (N - pow(k, n)) % pow(k, n + 1) == 0:
			ans += 1
			break
		n += 1
	k += 1
print(ans)


def main():
	n = int(input())
	ans = 0
	for k in divisors(n):
		if k == 1:
			continue
		if check(n, k):
			ans += 1
	ans += len([None for k in divisors(n - 1) if k != 1])
	print(ans)

def check(original_n, k):
	n = original_n
	while n % k == 0:
		n = n // k
	n = n % k
	return n == 1

def divisors(n):
	result = []
	for i in range(1, n + 1):
		if i * i > n:
			break
		if n % i == 0:
			result.append(i)
			d = n // i
			if d != i:
				result.append(d)
	return result
main()


n = int(input())
ans = [n]
if n != 2:
	ans.append(n - 1)
for k in range(2, min(n - 1, 1000001)):
	tmp = n
	while tmp % k == 0:
		tmp //= k
	tmp %= k
	if tmp == 1:
		ans.append(k)
if 1000000 < n:
	ks = [k for k in ans]
	for k in ks:
		if k < n - 1 and (n - 1) % k == 0:
			ans.append((n - 1) // k)
ans = set(ans)
print(len(ans))


import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left, bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil, pi
from operator import itemgetter

def I():
	return int(input())

def MI():
	return map(int, input().split())

def LI():
	return list(map(int, input().split()))

def LI2():
	return [int(input()) for i in range(n)]

def MXI():
	return [[LI()] for i in range(n)]

def SI():
	return input().rstrip()

def printns(x):
	print('\n'.join(x))

def printni(x):
	print('\n'.join(list(map(str, x))))
inf = 10 ** 17
mod = 10 ** 9 + 7
n = I()

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
u = len(make_divisors(n - 1)) - 1
lis = make_divisors(n)
lis.remove(1)

def divsub(n, k):
	flag = True
	while flag == True:
		n //= k
		if n % k == 1:
			return 1
			flag = False
		elif n % k != 0:
			return 0
			flag = False
ans = 0
for i in range(len(lis)):
	ans += divsub(n, lis[i])
print(ans + u)


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	divisors.sort()
	return divisors
s = len(make_divisors(N - 1))
p = make_divisors(N)
for i in range(1, len(p)):
	q = N
	while True:
		if q % p[i] == 0:
			q /= p[i]
		else:
			break
	if (q - 1) % p[i] == 0:
		s += 1
print(s - 1)


def calc_factors(N):
	i = 2
	factors = {N}
	while i * i <= N:
		if N % i == 0:
			factors.add(i)
			factors.add(N // i)
		i += 1
	return list(sorted(factors))
N = int(input())
if N == 2:
	print(1)
	return
ans = len(calc_factors(N - 1))
for fac in calc_factors(N):
	tmp = N
	while tmp % fac == 0:
		tmp //= fac
	if tmp % fac == 1:
		ans += 1
print(ans)


N = int(input())
import math
ans = []
l = int(math.log2(N))
for i in range(1, l + 1):
	if round(N ** (1 / i)) ** i == N:
		ans.append(round(N ** (1 / i)))
for i in range(2, round((N - 1) ** 0.5) + 1):
	if (N - 1) % i == 0:
		ans.append(i)
		if (N - 1) // i != i:
			ans.append((N - 1) // i)
if N > 2:
	ans.append(N - 1)
for i in range(2, round(N ** 0.5) + 1):
	if N % i == 0:
		n = N
		while n % i == 0:
			n //= i
		if n != 1 and n % i == 1:
			ans.append(i)
print(len(ans))


def main():
	N = int(input())
	if N <= 3:
		print(N - 1)
		return
	ans_1 = 0
	k = 2
	while k ** 2 <= N:
		n = N
		while n % k == 0:
			n //= k
		n %= k
		if n == 1:
			ans_1 += 1
		k += 1
	ans_2 = 1
	n = 1
	while n ** 2 < N:
		if (N - 1) % n == 0 and ((N - 1) // n) ** 2 > N:
			ans_2 += 1
		n += 1
	print(ans_1 + ans_2)

def __starting_point():
	main()
__starting_point()


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
ans = [2]
if N not in ans:
	ans.append(N)
if N % (N - 1) != 0 and N - 1 not in ans:
	ans.append(N - 1)
D = make_divisors(N)
for d in D:
	now = N
	if d == 1:
		continue
	while now % d == 0:
		now = now // d
	if now % d == 1:
		if d not in ans:
			ans.append(d)
ans2 = []
for a in ans:
	i = 1
	while a ** i <= N:
		x = a ** i
		now = N
		while now % x == 0:
			now = now // x
		if now % x == 1:
			if x not in ans2:
				ans2.append(x)
		i += 1
d2 = make_divisors(N - 1)
for d in d2:
	if d != 1 and d not in ans2:
		ans2.append(d)
print(len(ans2))


s = set()
a = s.add

def f(n):
	for i in range(1, int(n ** 0.5) + 1):
		if n % i < 1:
			a(i)
			if i != n // i:
				a(n // i)
n = int(input())
(f(n - 1), f(n))
a = 0
for i in s - {1}:
	m = n
	while m % i < 1:
		m //= i
	a += m % i < 2
print(a)


n = int(input())
if n == 2:
	count = 1
else:
	count = 2
divisor = []
d = 2
while d * d < n - 1:
	if (n - 1) % d == 0:
		count += 2
	d += 1
if d * d == n - 1:
	count += 1
d = 2
while d * d < n:
	if n % d == 0:
		divisor.append(d)
		divisor.append(n // d)
	d += 1
if d * d == n:
	divisor.append(d)
for d in divisor:
	tmp = n
	while tmp % d == 0:
		tmp //= d
	if tmp % d == 1:
		count += 1
print(count)


def yakusu(x):
	ya = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			ya.append(i)
			if i != x // i:
				ya.append(x // i)
	return ya
n = int(input())
(l, m, ans) = (yakusu(n), yakusu(n - 1), 0)
for i in range(1, len(l)):
	a = n
	while a % l[i] == 0:
		a = a // l[i]
	if (a - 1) % l[i] == 0:
		ans += 1
ans += len(m)
print(ans - 1)


N = int(input())

def divisor(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i != 0:
			continue
		res.append(i)
		if i * i != n:
			res.append(n // i)
	return res
ans = 0
d = []
for x in divisor(N):
	if x == 1:
		continue
	tmp = N
	while tmp % x == 0:
		tmp //= x
	tmp %= x
	if tmp == 1:
		ans += 1
ans += len(divisor(N - 1)) - 1
print(ans)


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

def test(n, ans_list):
	ans_list.append(n)
	ans_list = ans_list + make_divisors(n - 1)
	for ans in make_divisors(n):
		nn = n
		while nn % ans == 0:
			nn = nn / ans
		nn = nn % ans
		if nn == 1:
			ans_list.append(ans)
	return ans_list
n = int(input())
ans_list = []
answer = list(set(test(n, ans_list)))
print(len(answer))


def divisor(n):
	ret = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			(a, b) = (i, n // i)
			if a != b:
				ret += (a,)
				ret += (b,)
			else:
				ret += (a,)
	return sorted(ret)

def f(n):
	return divisor(n)[1:]

def solve(n):
	ans = f(n - 1)
	for k in f(n):
		N = n
		while N >= k:
			if N % k == 0:
				N = N // k
			else:
				N = N % k
		if N == 1:
			ans += (k,)
	print(len(ans))
	return 0
solve(int(input()))


N = int(input())
divs = set()
n = 1
while n * n <= N:
	if N % n == 0:
		divs.add(n)
		divs.add(N // n)
	n += 1
divs2 = set()
n = 1
while n * n <= N - 1:
	if (N - 1) % n == 0:
		divs2.add(n)
		divs2.add((N - 1) // n)
	n += 1
ans = len(divs2) - 1
for d in divs:
	if d == 1:
		continue
	n = N
	while n >= 1:
		if n == 1:
			ans += 1
			break
		if n % d == 0:
			n //= d
		else:
			if n % d == 1:
				ans += 1
			break
print(ans)


import math
import copy

def prime_factorize(n):
	a = [n]
	for i in range(2, math.floor(n ** 0.5) + 1):
		if n % i == 0:
			a.append(i)
			if n // i != i:
				a.append(n // i)
	return a
N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)
ans = 0
for i in prime_n:
	n = copy.deepcopy(N)
	while n % i == 0:
		n = n // i
	if n % i == 1:
		ans += 1
ans += len(prime_n_1)
if N > 2:
	print(ans)
else:
	print(1)


n = int(input())

def get_divisors(n):
	result = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			result.append(i)
			if n != i ** 2:
				result.append(n // i)
	result.sort()
	return result
c = 0
for number in get_divisors(n)[1:]:
	tmp = n
	while tmp % number == 0:
		tmp //= number
	if tmp % number == 1:
		c += 1
c += len(get_divisors(n - 1)) - 1
print(c)


def abc(n, i):
	if i == 1:
		return 0
	while not n % i:
		n = n // i
	return not (n - 1) % i
n = int(input())
e = {}
for i in range(1, int(pow(n, 0.5)) + 1):
	if not n % i:
		if abc(n, i):
			e[i] = 0
		if abc(n, n // i):
			e[n // i] = 0
n -= 1
c = 0
for i in range(1, int(pow(n, 0.5)) + 1):
	if not n % i:
		c += 1
		if i != n // i:
			c += 1
print(len(e) + c - 1)


def d(x):
	dl = []
	for i in range(1, int(x ** 0.5) + 1):
		if x % i == 0:
			dl.append(i)
			if i != x // i:
				dl.append(x // i)
	return dl
n = int(input())
ans = 0
t = d(n)
for i in t:
	if i == 1:
		continue
	tn = n
	while tn >= i:
		if tn % i == 0:
			tn //= i
		else:
			tn %= i
	if tn == 1:
		ans += 1
ans += len(d(n - 1)) - 1
print(ans)


n = int(input())
from numpy import sqrt
cnt = 2
rt = int(sqrt(n))
for i in range(2, rt + 1):
	if n % i == 0:
		m = n
		while m % i == 0:
			m = m // i
		if m % i == 1:
			cnt += 1
	elif (n - 1) % i == 0:
		cnt += 2
if n == rt ** 2 + 1:
	cnt -= 1
print(cnt)


n = int(input())
ans = 1
pr = []
if n == 2:
	print(1)
	exit()
if n == 3:
	print(2)
	exit()
for i in range(1, int(n ** 0.5)):
	if (n - 1) % i == 0:
		pr.append((n - 1) // i)
ans += len(pr)
for i in range(2, int(n ** 0.5 + 2)):
	t = n
	while t > i:
		if t % i:
			t %= i
		else:
			t //= i
	if t == 1 or t == i:
		ans += 1
if int(n ** 0.5 + 0.5) ** 2 == n:
	ans -= 1
print(ans)


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

def f(x):
	out = set()
	for i in range(1, int(x ** (1 / 2)) + 1):
		if x % i == 0:
			out.add(i)
			out.add(x // i)
	out = list(out)
	out.sort()
	return out[1:]
tmp = f(N)
for K in tmp:
	x = N
	while x >= K:
		if x % K == 0:
			x = x // K
		else:
			x = x % K
	if x == 1:
		ans += 1
tmp = f(N - 1)
ans += len(tmp)
print(ans)


N = int(input())

def divider(n):
	dividers = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			dividers.append(i)
			if i != n // i:
				dividers.append(n // i)
	dividers.sort()
	dividers.remove(1)
	return dividers
cnt = len(divider(N - 1))
for k in divider(N):
	n = N
	while n % k == 0:
		n /= k
	if n % k == 1:
		cnt += 1
print(cnt)


N = int(input())

def prime_cnt(N):
	(prime, i) = (set([2]), 1)
	while i * i <= N:
		if N % i == 0:
			prime.add(i)
			prime.add(N // i)
		i += 1
	prime.remove(1)
	return prime
import math
ans = 0
ans = prime_cnt(N - 1)
p = prime_cnt(N)
for i in p:
	n = N
	while n % i == 0:
		n /= i
	if (n - 1) % i == 0:
		ans.add(i)
print(len(ans))


def divisors(n):
	i = 1
	table = set()
	while i * i <= n:
		if not n % i:
			table.add(i)
			table.add(n // i)
		i += 1
	table = list(table)
	return table
N = int(input())
k = 2
res = 0
while k * k <= N:
	n = N
	while not n % k:
		n //= k
	if (n % k == 1 or n == 1) and n != N:
		res += 1
	k += 1
a = divisors(N - 1)
print(len(a) + res)


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

def calc(n, x):
	if x == 1:
		return n
	while n >= x:
		if n % x == 0:
			n //= x
		else:
			n %= x
	return n
n = int(input())
div_list = divisor(n)
ans = 0
for div in div_list:
	x = calc(n, div)
	if x == 1:
		ans += 1
ans += len(divisor(n - 1)) - 1
print(ans)


n = int(input())
ans = set()
for i in range(1, int(pow(n - 1, 0.5)) + 1):
	if (n - 1) % i == 0:
		ans.add((n - 1) // i)
		ans.add(i)
for i in range(2, int(pow(n, 0.5)) + 1):
	if n % i == 0:
		tmp = n
		while tmp % i == 0:
			tmp = tmp // i
		if (tmp - 1) % i == 0:
			ans.add(i)
print(len(ans))


N = int(input())
import math
ans = []
for i in range(1, round((N - 1) ** 0.5) + 1):
	if (N - 1) % i == 0:
		ans.append(i)
		if (N - 1) // i != i:
			ans.append((N - 1) // i)
ans.remove(1)
ans.append(N)
for i in range(2, round(N ** 0.5) + 1):
	if N % i == 0:
		n = N
		while n % i == 0:
			n //= i
		if n % i == 1:
			ans.append(i)
print(len(ans))


N = int(input())

def check(p):
	_N = N
	while _N % p == 0:
		_N //= p
	return (_N - 1) % p == 0
n = int(N ** 0.5) + 1
P0 = set([N])
P1 = set([N - 1])
for i in range(2, n + 1):
	if (N - 1) % i == 0:
		P1.add(i)
		P1.add((N - 1) // i)
	if N % i == 0:
		P0.add(i)
		P0.add(N // i)
P0.discard(1)
P1.discard(1)
ans = len(P1)
for p in P0:
	ans += check(p)
print(ans)


n = int(input())
count = set([n, n - 1])
for i in range(2, int(n ** 0.5) + 5):
	if (n - 1) % i == 0:
		count.add(i)
		count.add((n - 1) // i)
	if n % i == 0:
		a = n
		while a % i == 0:
			a //= i
		if a % i == 1:
			count.add(i)
if 1 in count:
	print(len(count) - 1)
else:
	print(len(count))


n = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
cnt = len(make_divisors(n - 1)) - 1
base = make_divisors(n)
for x in base[1:]:
	org = n
	while org % x == 0:
		org = org / x
	if org % x == 1:
		cnt += 1
print(cnt)


N = int(input())
if N == 2:
	print(1)
	exit()
S = set([N - 1])
lst = [N]
i = 2
while i * i <= N - 1:
	if (N - 1) % i == 0:
		S.add(i)
		S.add((N - 1) // i)
	i += 1
i = 2
while i * i < N:
	if N % i == 0:
		lst.append(i)
		lst.append(N // i)
	i += 1
if i * i == N:
	lst.append(i)
lst.sort()
for l in lst:
	if l in S:
		continue
	_N = N
	while _N % l == 0:
		_N //= l
	if _N % l == 1:
		S.add(l)
print(len(S))


n = int(input())
ns = int(n ** 0.5)
nms = int((n - 1) ** 0.5)
p = [n]
for i in range(2, ns + 1):
	if n % i == 0:
		p.append(i)
		if i != n // i:
			p.append(n // i)

def chd(x, k):
	while x % k == 0:
		x = x // k
	return int(x % k == 1)
count = 0
for i in p:
	count += chd(n, i)
for i in range(2, nms + 1):
	if (n - 1) % i == 0:
		count += 1
		if i != (n - 1) // i:
			count += 1
print(count + 1 - (n == 2))


N = int(input())

def make_divisors(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors
a = make_divisors(N)
b = make_divisors(N - 1)
cnt = 0
for i in a:
	if i == 1:
		continue
	k = N
	while k % i == 0:
		k //= i
	if k % i == 1:
		cnt += 1
ans = len(b) - 1 + cnt
print(ans)


N = int(input())
ans = 0
x = N - 1
for i in range(2, int(x ** (1 / 2)) + 1):
	if x % i == 0:
		ans += 2
if int(x ** (1 / 2)) ** 2 == x:
	ans -= 1
for i in range(2, int(N ** (1 / 2)) + 1):
	a = N
	if a % i == 0:
		while a % i == 0:
			a //= i
		if a % i == 1:
			ans += 1
		b = N // i
		if b == i:
			continue
		a = N
		while a % b == 0:
			a //= b
		if a % i == 1:
			ans += 1
print(ans + 2)


num = int(input())
n = num
num -= 1
result = 1
for i in range(2, int(pow(num, 0.5)) + 1):
	c = 0
	while num % i == 0:
		num //= i
		c += 1
	if c > 0:
		result *= c + 1
if num > 1:
	result *= 2
result -= 1
r = set()
for i in range(2, int(pow(n, 0.5)) + 1):
	num = n
	if num % i == 0:
		r.add(i)
		r.add(n // i)
r.add(n)
for i in r:
	num = n
	while num % i == 0:
		num //= i
	if num % i == 1:
		result += 1
print(result)


N = int(input())

def divisor(x):
	ret = set()
	for i in range(1, int(x ** 0.5 + 1)):
		if x % i == 0:
			ret.add(i)
			ret.add(x // i)
	return ret
ans = 0
for k in divisor(N):
	if k == 1:
		continue
	tmp = N
	while tmp % k == 0:
		tmp //= k
	if tmp % k == 1:
		ans += 1
ans += len(divisor(N - 1)) - 1
print(ans)


n = int(input())
if n == 2:
	print(1)
	exit()
Ans = set([n - 1])
for i in range(2, int((n - 1) ** (1 / 2)) + 1):
	if (n - 1) % i == 0:
		Ans.add(i)
		Ans.add((n - 1) // i)
Div = set([n])
for i in range(2, int(n ** (1 / 2)) + 1):
	if n % i == 0:
		Div.add(i)
		Div.add(n // i)
for d in Div:
	m = n
	while m % d == 0:
		m //= d
	if m % d == 1:
		Ans.add(d)
print(len(Ans))


n = int(input())
fct1 = []
fct2 = []
for i in range(1, int(n ** (1 / 2)) + 10):
	if n % i == 0:
		fct1.append(i)
		fct2.append(n // i)
	if (n - 1) % i == 0:
		fct1.append(i)
		fct2.append((n - 1) // i)
fct = set(fct1 + fct2)
if 1 in fct:
	fct.remove(1)
ans = 0
for k in fct:
	n2 = n
	while n2 and n2 % k == 0:
		n2 //= k
	n2 %= k
	if n2 == 1:
		ans += 1
print(ans)


def make_yakusuu(n):
	r_list = []
	i = 1
	while i * i <= n:
		if n % i == 0:
			r_list.append(i)
			r_list.append(n // i)
		i += 1
	return sorted(r_list)
n = int(input())
tmp = make_yakusuu(n)
out = []
for i in tmp:
	m = n
	if i == 1:
		continue
	while m % i == 0:
		m //= i
	if m % i == 1 or m % i == 0:
		out.append(i)
out += make_yakusuu(n - 1)
print(len(set(out)) - 1)


n = int(input())
p = n
yakusu = []
for i in range(1, int(n ** 0.5) + 1):
	if n % i == 0:
		yakusu.append(i)
		if i != n // i:
			yakusu.append(n // i)
p -= 1
yakusu_1 = []
for i in range(1, int(p ** 0.5) + 1):
	if p % i == 0:
		yakusu_1.append(i)
		if i != p // i:
			yakusu_1.append(p // i)
ans = len(yakusu_1) - 1
for x in yakusu:
	r = n
	if x != 1:
		while r % x == 0:
			r //= x
		if (r - 1) % x == 0:
			ans += 1
print(ans)


def make_divisors(n):
	(lower_divisors, upper_divisors) = ([], [])
	i = 1
	while i * i <= n:
		if n % i == 0:
			lower_divisors.append(i)
			if i != n // i:
				upper_divisors.append(n // i)
		i += 1
	return lower_divisors + upper_divisors[::-1]
n = int(input())
l = make_divisors(n - 1)
l2 = make_divisors(n)
del l2[0]
ans = len(l) - 1
for i in l2:
	k2 = n
	while True:
		if k2 % i == 1:
			ans += 1
		k2 /= i
		if k2 % 1 != 0:
			break
print(ans)


N = int(input())

def divisors(n):
	ret = set()
	m = 1
	while m * m <= n:
		if n % m == 0:
			ret.add(m)
			ret.add(n // m)
		m += 1
	return ret
a = divisors(N)
b = divisors(N - 1)
ans = len(b) - 1
for k in a:
	if k == 1:
		continue
	n = N
	while n % k == 0:
		n //= k
	if n % k == 1:
		ans += 1
print(ans)


def pf(x):
	plist = [1]
	p = 2
	while x > 1:
		t = 0
		while x % p == 0:
			x /= p
			t += 1
		now = list(plist)
		for i in range(t):
			now = list(map(lambda y: int(y * p), now))
			plist.extend(now)
		if p > int(x ** 0.5) + 1:
			p = x
		elif p == 2:
			p = 3
		else:
			p += 2
	return plist
N = int(input())
ans = len(pf(N - 1)) - 1
for x in pf(N)[1:]:
	M = N
	while M > 1 and M % x == 0:
		M //= x
	if M == 1 or M % x == 1:
		ans += 1
print(ans)


def divisors(n):
	ret = []
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			ret.append(i)
			if n // i != i:
				ret.append(n // i)
	return ret
n = int(input())
if n == 2:
	print(1)
else:
	divs1 = divisors(n)
	divs2 = divisors(n - 1)
	cand = divs2
	for val in divs1:
		tmp = n
		while tmp % val == 0:
			tmp = tmp // val
		if tmp % val == 1:
			cand.append(val)
	if n not in cand:
		cand.append(n)
	if n - 1 not in cand:
		cand.append(n - 1)
	print(len(cand))


from math import ceil

def enum_divisor(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i != 0:
			continue
		res.append(i)
		if i * i != n:
			res.append(n // i)
	return res
ans = 0
n = int(input())
for x in enum_divisor(n):
	if x == 1:
		continue
	tmp = n
	while tmp % x == 0:
		tmp //= x
	if tmp % x == 1:
		ans += 1
ans += len(enum_divisor(n - 1)) - 1
print(ans)


import math
import copy
n = int(input())
m = int(math.sqrt(n) + 0.1) + 1

def f(x):
	a = copy.copy(n)
	while a % x == 0:
		a /= x
	return a % x == 1
ans = {n}
if n > 2:
	ans.add(n - 1)
for k in range(2, m):
	if (n - 1) % k == 0:
		ans.add(k)
		ans.add((n - 1) // k)
	elif f(k):
		ans.add(k)
print(len(ans))