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: interview

Starter code:

Solutions:
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))
divisors = []
for i in make_divisors(n):
    j = n
    if i != 1:
        while j % i == 0:
            j //= i
        if (j - 1) % i == 0:
            divisors.append(i)
print((ans + len(divisors) - 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)


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)


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))

n = int(input())

# n % k = 1 の数
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

# n % k = 0 の場合
# nを素因数分解する
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]))

# 直積を求めることで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 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)

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
#nの約数を抽出する関数を定義(1以外)

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)

import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
#N = int(input())
#A = list(map(int,input().split()))
#S = list(input())[:-1]
#S.remove("\n")
#N,M = map(int,input().split())
#S,T = map(str,input().split())
#A = [int(input()) for _ in range(N)]
#S = [list(input())[:-1] for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
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]
ans = {N}
li1 = make_divisors(N-1)[1:]
for er in li1:
    ans.add(er)
li0 = make_divisors(N)[1:-1]
for i in li0:
    n = N
    while n % i == 0:
        n /= i
    if (n-1) % i == 0:
        ans.add(i)
print((len(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 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)
# print(sorted(divs))
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)


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)

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))



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()

# 方針は解説と全く同じなので割愛
# なんで2のときだけ特別になった?
# get_divisors(1) が[1]となるべきところで空配列[]になっているせいで、
# 最終的な答えが1小さくなってしまっていた。

n = int(input())

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

# 約数列挙
# ABC136Eより
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:  # 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)


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 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)))

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())

"""
愚直にやると、Kを2～Nの範囲で全部調べて数え上げる。N <= 10**12 なので間に合わない。


たとえば N=100だと、
[2, 3, 4, 9, 10, 11, 33, 99, 100]
が条件を満たす数字になる。

割り算を行わないとき、明らかに N % K = 1 になる
これは、「NをKで割ったら、１あまる」であるから、「N-1をKでわったら割り切れる」ともいえる。
なので、割り算が起こらないものは、N-1の約数。

割り算が起こるやつは、割れるだけ割った後、余りを調べればよい。
"""



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)

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()

    # memo
    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
            # print("u",u,j,nn,r)

    d = pr.division(n-1)
    # print("d",d)
    k = 1
    for _,v in d:
        k *= v + 1
    r += k - 1

    return r

print(main())





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)))
#answer.sort()

print(len(answer))

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 main():
    N = int(input())
    if N <= 3:
        print(N - 1)
        return
    # (1) 2 <= k <= sqrt(N) で題意を満たすkの個数
    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
    # (2) sqrt(N) < k <= N で題意を満たすkの個数
    # sqrt(N)より大きいN-1の約数の個数 + 1 (k = N)
    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()

def calc_factors(N):
    """
    約数をlistでreturn
    この問題はK>1なので、約数に1を含めてない
    """
    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)


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())

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)

"""
0, K, 2K, 3K, 4K, ... = N-1 のとき, 答え.
"""
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 resolve():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                # divisors.append((i, n // i)) # [(1,max), (2, max-1)]
                divisors += [i,n // i]  # [1,2,3,5]
        divisors.sort()
        return divisors

    N = int(input())
    ans = 0

    # K で割り切れない時
    div1 = set(make_divisors(N-1))
    ans += len(div1) - 1

    # K で割り切れる時
    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()

# F - Division or Subtraction
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)

# coding: utf-8
# hello worldと表示する
#dpでできないかな？
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)

    # divisors.sort()
    return divisors
u=len(make_divisors(n-1))-1
lis=make_divisors(n)
lis.remove(1)
#print(lis)
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
#print(divsub(10,5))
ans=0
for i in range(len(lis)):
    ans+=divsub(n,lis[i])
print(ans+u)

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
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

N = int(input())

#nの約数列挙
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 #sortされていない

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):
    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())


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
# print(L1)
for [a, b] in L1:
    s *= (b + 1)
# print(s)


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)

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)


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)

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)


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)

    # divisors.sort()
    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)


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
    while True:
        if n%div != 0 or n==1:
            break
        n //= div
    if n%div == 1:
        ans += 1

print(ans)


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)
# print(div)
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:
#     if i > 1:    
#         t = n-1
#         while t:
#             if t == 1:
#                 ans += 1
#                 a += [i]
#             t //= i
#         # if n%(i-1) == 1:
#         #     ans += 1
#         #     a += [i-1]
# print(ans)
# print(a)
# print(div)
# print(div2)
for i in div2:
    a+=[i]
a = set(a)
# print(a)
print(len(a)-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
import sys
sys.setrecursionlimit(10**7)
def func(N,d):
    if d==1:
        return False
    while N>1:
        if N%d==0:
            N//=d
        else:
            if (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)
#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)

    # divisors.sort()
    return divisors


#print(make_divisors(3141))
#N, N-1, 2
#%*==1
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)
#print(ans)

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
#print(ans2)
d2=make_divisors(N-1)
for d in d2:
    if d!=1 and (d not in ans2):
        ans2.append(d)
#print(ans2)
print(len(ans2))

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)

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

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

#print(ans1)

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

list2 = factorization(N)
#print(list2)
factorlist = [1]

for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3

factorlist = factorlist[1:-1]
#print(factorlist)
ans2 = 1
for item in factorlist:
  if operation(item):
    #print(item)
    ans2 +=1


ans += ans2
#print(ans2)

print(ans)

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)


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
    #ans += (N - 1)//K
    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)



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

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())
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))

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

    # K > 1

    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

    # N % K == 1
    # (N-1) % K == 0
    # K > 1

    ans = 0
    ans += len(divisor_set(N - 1))

    # N % K == 0
    # N //= K ---> M
    # (M-1) % K == 0

    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()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())

__starting_point()

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)


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 = len(make_divisors(N-1))-1

for i in make_divisors(N):
  if i == 1:
    continue
    
  Ni = int(N/i)
  
  while Ni % i == 0:
    Ni = int(Ni/i)
    
  if Ni % 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)


# 1は除外
# ・N-1の約数は全て対象
# ・Nの約数でsqrt(N)以下の数について、Nで割れなくなるまで割って、最後にあまりが1になればOK
# ・N自身は必ず対象
# これを足し合わせる

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
  
# N-1の約数の個数
ans = len(make_divisors(N-1)) - 1

def check(n,x):
  # xで割った余りがxの倍数でなくなるまでxで割る
  # xの倍数でなくなったときにxで割って1余ればOK
  while n % x == 0:
    n //= x
  return (n % x == 1)

# Nの約数で2以上sqrt(N)以下の数
for i in range(2,int(N ** 0.5) + 1):
  if N % i == 0:
    if check(N,i):
      ans += 1

# N自身も対象
ans += 1

print(ans)


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)

n = int(input())

if n == 2:
    print(1)
    return
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)

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)

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

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

#print(ans1)

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

list2 = factorization(N)
#print(list2)
factorlist = [1]

for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3

factorlist = factorlist[1:-1]
#print(factorlist)
ans2 = 1
for item in factorlist:
  if operation(item):
    #print(item)
    ans2 +=1


ans += ans2
#print(ans2)

print(ans)

# coding: utf-8
import sys

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

N = ir()
# 候補はNかN-1の約数
answer = 0

def make_divisors(n):  # 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)


# 1は除外
# ・N-1の約数は全て対象
# ・Nの約数で、sqrt(N)以下であればOK　ただしN自身は対象
# これを足し合わせる

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
  
# N-1の約数の個数
ans = len(make_divisors(N-1)) - 1

def check(n,x):
  # xで割った余りがxの倍数でなくなるまでxで割る
  # xの倍数でなくなったときにxで割って1余ればOK
  while n % x == 0:
    n //= x
  return (n % x == 1)

# Nの約数で2以上sqrt(N)以下の数
for i in range(2,int(N ** 0.5) + 1):
  if N % i == 0:
    if check(N,i):
      ans += 1

# N自身も対象
ans += 1

print(ans)


n = int(input())

# 例外処理
if n == 2:
    print(1)
    return
if n == 3:
    print(2)
    return

# n % k = 1 の数
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

# n % k = 0 の場合
# nを素因数分解する
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]))

# 直積を求めることで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 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)


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)

  # divisors.sort()
  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)


N = int(input())

"""
引き算のみ
N mod K == -1
N-1 mod K == 0
K はN-1の約数

割り算が含まれる
KはNの約数
大した個数ないので、確かめる。
"""

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) # 1を除く

n = int(input())

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

# 約数列挙
# ABC136Eより
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:  # 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)


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 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)


# 約数
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)
# print(sorted(divs))
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)

import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    P = []
    for k in range(1,1+int((N-1)**(1/2))):
        if (N-1)%k == 0:
            P.append((N-1)//k)
            P.append(k)
    P = set(P)
    ans = len(P)
    for k in range(2,1+int(N**(1/2))):
        if N%k == 0:
            t = N//k
            while t%k == 0:
                t //= k
            if t%k == 1:
                ans += 1
    print(ans)
def __starting_point():
    main()

__starting_point()

import sys
from math import gcd

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

"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
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


factors = factorization(N)
ans = 0

# K^i
tmp = factors[0][1]
for k, i in factors:
    tmp = gcd(tmp, i)
ptn = 1
if tmp != 1:
    for k, i in factorization(tmp):
        ptn *= i+1
ans += ptn

# ak+1
ptn = 1
for k, i in factorization(N-1):
    ptn *= i+1
ptn -= 1  # k=1のときを除外
ans += ptn

# (ak+1)*k^i
ptn = 0
for f, n in factors:
    for i in range(1, n+1):
        k = f**i
        tmp = N
        while True:
            if tmp%k!=0:
                break
            tmp = tmp/k
        ptn += ((tmp-1)%k==0 and tmp!=1)
ans += ptn

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
# sympy as syp(素因数分解とか)
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():  #startline-------------------------------------------
    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() #endline===============================================
__starting_point()

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 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)

import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

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


# ===CODE===
# 約数を列挙　n=10^12までいける
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()
    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()


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()


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))

# -*- coding: utf-8 -*-
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 = int(1e09) + 7
MOD = 998244353
INF = int(1e15)


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():
    # sys.setrecursionlimit(1000000)
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


def __starting_point():
    main()

__starting_point()

# 方針は解説と全く同じなので割愛

n = int(input())

# 約数列挙
# ABC136Eより
def get_divisors(num):
    if num == 1:
        return [1]
    
    divisors = []
    for d in range(1, num):
        if d * d > num:
            break
        if num % d == 0: #約数
            divisors.append(d)
            if d * d != num:  # 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)



def solve1(n):
    # n = k ^ a
    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):
    # n = a * k + 1
    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)
    # print res
    return len(res)

def solve(n):
    s1 = solve1(n)
    s2 = solve2(n)
    s3 = solve3(n)
    # print sorted(s1 | s2 | s3)
    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))


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())
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

for k in range(1, int(N**0.5)+1):
    if (N-1)%k==0:
        ans.add(k)
        ans.add((N-1)//k)
    if N%k==0:
        if check(N, k):
            ans.add(k)
        if check(N, N//k):
            ans.add(N//k)

ans.remove(1)
print(len(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)


#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
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())
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 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())
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())

# 約数
# O(N**0.5)
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)

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())
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)

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)

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): #N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == 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))
    #print(ans)


    return 0

def __starting_point():
    solve()
__starting_point()

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().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)

    # divisors.sort()
    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)

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)))



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())

# n % k = 1 の数
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

# n % k = 0 の場合
# nを素因数分解する
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]))

# 直積を求めることで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)

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)


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)

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
            else:
                if 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()