qyliang/CodeNanoFix huggingface dataset:
# Buggy code:
import sys
N, M = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split))
li.sort(reverse=False)
if li[M-1] < sum(li)/(4*M):
  print('No')
else:
  print('Yes')

# Fixed code:
import sys
N, M = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
li.sort(reverse=True)
if li[M-1] < sum(li)/(4*M):
  print('No')
else:
  print('Yes')
# Buggy code:
N, M = input().split(' ')
lis1 = map(int, input().split(' '))
S = sum(lis1)
thresh = S / (4 * M)
lis2 = sorted(lis1)
if lis2[M - 1] < thresh:
  print 'No'
else:
  print 'Yes'

# Fixed code:
N, M = map(int, input().split(' '))
lis1 = list(map(int, input().split(' ')))
S = sum(lis1)
thresh = S / (4 * M)
lis2 = sorted(lis1)
if lis2[-M] < thresh:
  print('No')
else:
  print('Yes')
# Buggy code:
n,m=map(int,input().split())
a=list(map(int, input().split()))

cnt=0
sou=sum(a)
print(sou)
for i in range(n):
    if a[i]>=sou/(4*m):
        cnt+=1
print('Yes' if cnt>=m else 'No')


# Fixed code:
n,m=map(int,input().split())
a=list(map(int, input().split()))

cnt=0
sou=sum(a)
for i in range(n):
    if a[i]>=sou/(4*m):
        cnt+=1
print('Yes' if cnt>=m else 'No')
# Buggy code:
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
print("YNeos"[sum([sum(a)/(4*m)>=a[i] for i in range(m)])==m::2])


# Fixed code:
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())),reverse=True)
print("YNeos"[sum([sum(a)/(4*m)<=a[i] for i in range(m)])!=m::2])
# Buggy code:
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(tmp)

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)


# Fixed code:
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)
# Buggy code:
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())
md = make_divisors(N)
mdd = make_divisors(N-1)
se = set(md+mdd)
li = list(se)
ans = 0
for i in li:
  if i != 1:
    n = N
    while n >= i:
      if n % i == 0:
        n = n // i
      else:
        n = n - i
    if n == 1:
      ans += 1
print(ans)

# Fixed code:
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())
md = make_divisors(N)
mdd = make_divisors(N-1)
se = set(md + mdd)
li = list(se)
ans = 0
for i in li:
  if i != 1:
    n = N
    while n >= i:
      if n % i == 0:
        n = n // i
      else:
        n = n % i
    if n == 1:
      ans += 1
print(ans)
# Buggy code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    max_i = int(math.log2(N))
    div = []
    for i in range(1,int(math.sqrt(N))+1):
        if N % i == 0:
            div.append((i,N//i)); div.append((N//i,i))

    ans = 0
    for a,b in div:
        if a == 1:
            for i in range(1,int(math.sqrt(b-1))+1):
                if b % i == 1:
                    ans += (1 if i*i == b-1 or i == 1 else 2)
        else:
            for i in range(1,max_i+1):
                c = round(math.pow(a,1/i))
                if c ** i == a:
                    if b % c == 1: ans += 1
    print(ans)

if __name__ == '__main__':
    main()

# Fixed code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()
    max_i = int(math.log2(N))
    div = []
    for i in range(1,int(math.sqrt(N))+1):
        if N % i == 0:
            div.append((i,N//i)); div.append((N//i,i))

    ans = 0
    for a,b in div:
        if a == 1:
            for i in range(1,int(math.sqrt(b-1))+1):
                if (b-1) % i == 0:
                    p = 2 - (i*i == b-1) - (i == 1)
                    ans += p
        else:
            for i in range(1,max_i+1):
                c = round(math.pow(a,1/i))
                if c ** i == a:
                    if b % c == 1: ans += 1
    print(ans)

if __name__ == '__main__':
    main()
# Buggy code:
import math


N = int(input())

nn = int(math.sqrt(N))

ans = 0
for x in range(2,nn+1):

    if N % x > 1:
        continue

    if N % x == 1:
        ans += 1
        continue
    
    tmp = N
    while True:
        tmp = tmp / x
        if tmp % x  == 1:
            ans += 1
            break
        elif tmp == x :
            ans += 1
            break
        elif tmp % x >= 1:
            break

print(ans+2)






# Fixed code:
import math


N = int(input())

nn = int(math.sqrt(N))
# nn = int(N / 2)

ans = 1
for x in range(2,nn+1):

    if N % x == 1:
        ans += 1
        continue
    
    if N % x > 1:
        continue

    tmp = N
    while tmp > x:
        tmp = tmp / x
        if tmp % x == 1 :
            ans += 1
            break
        elif tmp % x > 1 :
            break
        elif tmp == x:
            ans += 1
            break

x = 1
tmp = N - 1
while tmp / x  > nn:
    if tmp % x == 0:
        ans += 1
    x += 1

print(ans)
# Buggy code:
import math

N = int(input())

cnt = 0

if N == 2:
  print(1)
  exit()

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
res1 = sorted(make_divisors(N))
print(res1)
res1 = res1[1:math.ceil(len(res1)/2)]

for num in res1:
  kensa = N
  while True:
    if kensa % num == 0:
      kensa = kensa // num
      continue
    break
  if kensa % num == 1:
    cnt += 1

res2 = sorted(make_divisors(N-1))
cnt += len(res2[1:])+1

print(cnt)

# Fixed code:
import math
 
N = int(input())
 
cnt = 0
 
if N == 2:
  print(1)
  exit()
 
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
res1 = sorted(make_divisors(N))
res1 = res1[1:math.ceil(len(res1)/2)]
 
for num in res1:
  kensa = N
  while True:
    if kensa % num == 0:
      kensa = kensa // num
      continue
    break
  if kensa % num == 1:
    cnt += 1
 
res2 = sorted(make_divisors(N-1))
cnt += len(res2[1:])+1
 
print(cnt)
# Buggy code:
N = int(input())
cnt = 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
N1_yakusu = make_divisors(N-1)
N_yakusu = make_divisors(N)
cnt += len(N1_yakusu)
for s in N_yakusu:
    new_N = s
    while(new_N%K==0):
        new_N = new_N//K
    if(new_N%K == 1):
        cnt += 1
print(cnt)

# Fixed code:
N = int(input())
cnt = 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.pop(0)
    return divisors
N1_yakusu = make_divisors(N-1)
N_yakusu = make_divisors(N)
cnt += len(N1_yakusu)
for K in N_yakusu:
    new_N = N
    while(new_N%K==0):
        new_N = new_N//K
    if(new_N%K == 1):
        cnt += 1
print(cnt)
# Buggy code:
n = int(input())

count = 1
divisor = []

d = 2
while d * d < n - 1:
  if n % d == 1:
    count += 2
  d += 1
if d * d == n:
  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)
count += 1

for d in divisor:
  tmp = n
  while tmp % d == 0:
    tmp //= d
  if tmp % d == 1:
    count += 1

# Fixed code:
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)
# Buggy code:
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)
print(ans)

# Fixed code:
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)
# Buggy code:
import sys

def solve():
      input = sys.stdin.readline
      N = int(input())
      used = {N}
      if N > 2: used |= {N - 1}
      for i in range(2, N):
            if i ** 2 > N: break
            else:
                  d = i
                  while d * i <= N: d *= i
                  if d == N or (N - d) % i == 0: used |= {i}
                  if (N - 1) % i == 0:
                        used |= {i}
                        if i ** 2 != N - 1: used |= {(N - 1) // i}
      print(len(used))
      #print(used)

      return 0

if __name__ == "__main__":
      solve()

# Fixed code:
import sys

def solve():
      input = sys.stdin.readline
      N = int(input())
      used = {N}
      if N > 2: used |= {N - 1}
      for i in range(2, N):
            if i ** 2 > N: break
            else:
                  if N % i == 0:
                        d = N
                        while d % i == 0:
                              d //= i
                        if d % i == 1: used |= {i}
                  if (N - 1) % i == 0:
                        used |= {i}
                        if i ** 2 != N - 1: used |= {(N - 1) // i}
      print(len(used))
      #print(used)

      return 0

if __name__ == "__main__":
      solve()
# Buggy code:
n=int(input())
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=[n]
for i in range(2,int(nn*0.5)+1):
  if n%i==0:
    l.append(i)
    l.append(n//i)
for j in l:
  m=n
  while m%j==0:
    m//=j
  if m%j==1:
    ans.add(j)
print(len(ans))

# Fixed code:
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))
# Buggy code:
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(k1)
        if check(N, N//k):
            ans.add(k2)

ans.remove(1)
print(len(ans))

# Fixed code:
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))
# Buggy code:
n = int(input())


def check(n, k):
    while n % k == 0:
        n = n // k
    if n >= k:
        n = n - k * (n // k)
    return n


def count(n):
    total = 0
    cands = set([n, n-1])
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cands.add(i)
            cands.add(n // i)
    for i in range(2, int(n ** 0.5) + 1):
        if (n-1) % i == 0:
            cands.add(i)
            cands.add((n - 1) // i)
    for k in cands:
        if k == 1:
            continue
        if check(n, k) == 1:
            total += 1
    return total


# Fixed code:
n = int(input())


def check(n, k):
    while n % k == 0:
        n = n // k
    if n >= k:
        n = n - k * (n // k)
    return n


def count(n):
    total = 0
    cands = set([n, n-1])
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cands.add(i)
            cands.add(n // i)
    for i in range(2, int(n ** 0.5) + 1):
        if (n-1) % i == 0:
            cands.add(i)
            cands.add((n - 1) // i)
    for k in cands:
        if k == 1:
            continue
        if check(n, k) == 1:
            total += 1
    return total


print(count(n))
# Buggy code:

import sys
sys.setrecursionlimit(10**9)

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

ds = set(make_divisors(N)) | set(make_divisors(N-1))

def check(n,k):
    if n<k:
        return n==1
    elif n%k==0:
        return check(n//k,k)
    else:
        return check(n-k,k)

ds.remove(1)
cnt = 0
for d in ds:
    # print(d)
    if check(N,d):
        cnt+=1
print(cnt)


# Fixed code:

import sys
sys.setrecursionlimit(10**9)

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

ds = set(make_divisors(N)) | set(make_divisors(N-1))

def check(n,k):
    if n<k:
        return n==1
    elif n%k==0:
        return check(n//k,k)
    else:
        return check(n%k,k)

ds.remove(1)
cnt = 0
for d in ds:
    # print(d)
    if check(N,d):
        cnt+=1
print(cnt)
# Buggy code:
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)
      ans += divisor(m)
  ans += divisor(n - 1)
  return ans
n = int(input())
print(function(n))

# Fixed code:
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))
# Buggy code:
import math


def list_divisor(n):
    divisor1 = {1}
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisor1.add(i)

    divisor2 = {n}
    for i in divisor1:
        divisor2.add(n // i)

    return divisor1 & divisor2


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

    sub_only = len(list_divisor(n - 1)) - 1

    div_included = 0
    for d in list_divisor(n):
        n1 = n // d
        while n1 % d == 0:
            n1 = n1 // d

        if d in list_divisor(n1 - 1):
            div_included += 1
    
    print(sub_only + div_included)
    

if __name__ == '__main__':
    main()


# Fixed code:
import math


def list_divisor(n):
    divisor1 = {1}
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            divisor1.add(i)

    divisor2 = {n}
    for i in divisor1:
        divisor2.add(n // i)

    return divisor1 | divisor2


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

    sub_only = len(list_divisor(n - 1)) - 1

    div_included = 0
    for d in (list_divisor(n) - {1}):
        n1 = n // d
        while n1 % d == 0:
            n1 = n1 // d

        if n1 == 1:
            div_included += 1
            continue

        if d in list_divisor(n1 - 1):
            div_included += 1

    print(sub_only + div_included)


if __name__ == '__main__':
    main()
# Buggy code:
def calc_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 div_or_sub(n, k):
    while k <= n:
        if n % k == 0:
            n //= k
        else:
            n %= k
        return n

n = int(input())
cnt = len(calc_divisors(n - 1)) - 1
n_divisors = calc_divisors(n)
for divisor in n_divisors:
    if div_or_sub(n, divisor) == 1:
        cnt += 1
print(cnt)

# Fixed code:
def calc_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 div_or_sub(n, k):
    while k <= n:
        if n % k == 0:
            n //= k
        else:
            n %= k
    return n

n = int(input())
cnt = len(calc_divisors(n - 1)) - 1
n_divisors = calc_divisors(n)
for divisor in n_divisors[1:]:
    if div_or_sub(n, divisor) == 1:
        cnt += 1
print(cnt)
# Buggy code:
N = int(input())

def check(p):
  _N = N
  while _N%p == 0:
    _N //= p
  return ((_N-1)%p == 0) or (_N == 1)

n = int(N**0.5)
P0 = set([N])
P1 = set([N-1])
for i in range(2, n+1):
  if N%i == 0:
    P0.add(i)
    P0.add(N//i)

n = int((N-1)**0.5)
for i in range(2, n+1):
  if N%i == 0:
    P1.add(i)
    P1.add(N//i)

ans = len(P1)
for p in P0:
  ans += check(p)

print(ans)


# Fixed code:
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)
# Buggy code:
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 make_divisors2(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0 and (n//i)%i == 1:
            divisors.append(i)

    # divisors.sort()
    return divisors

n=int(input())
l = make_divisors(n-1)
ans = len(l)
l2 = make_divisors2(n)
ans += len(l2)
print(ans)

# Fixed code:
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 make_divisors2(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)

    # divisors.sort()
    return divisors

n=int(input())
l = make_divisors(n-1)
ans = len(l)

l2 = make_divisors2(n)
for i in l2[1:]:
    n1 = n
    while n1%i == 0:
        n1 = n1//i
    if n1%i == 1:
        ans += 1
print(ans)
# Buggy code:
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 main():
    n = int(input())
    ans = 0
    div = make_divisors(n)
    for i in div[::1]:
        var = n
        while not var%i:
            var = var // i
        if var%i == 1:
            ans += 1
    ans += len(make_divisors(n-1)) - 1
    print(ans)

main()


# Fixed code:
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 main():
    n = int(input())
    ans = 0
    div = make_divisors(n)
    for i in div[1:]:
        var = n
        while not var%i:
            var = var // i
        if var%i == 1:
            ans += 1
    ans += len(make_divisors(n-1)) - 1
    print(ans)

main()
# Buggy code:
from copy import deepcopy
import numpy as np
def factor(N):
    ans = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(i)
    return ans

def check(K,N):
    while N>=K:
        if N%K == 0:
            N = N//K
        else:
            N = N%K
    if N%K == 1:
        return True
    else:
        return False

N = int(input())
ans = len(factor(N-1)[1:])
for K in factor(N)[1:]:
    if check(K,N):
        ans += 1

print(ans)   


# Fixed code:
import numpy as np
def factor(N):
    ans = []
    for i in range(1,int(np.sqrt(N))+1):
        if N%i == 0:
            ans.append(i)
            if N//i != i:
                ans.append(N//i)
    return ans

def check(K,N):
    while N >= K:
        if N%K == 0:
            N //= K
        else:
            N %= K
    if N%K == 1:
        return True
    else:
        return False

N = int(input())
ans = len(factor(N-1))-1

for K in factor(N)[1:]:
    if check(K,N):
        ans += 1

print(ans)