output_description: Print the number of choices of K in which N becomes 1 in the end.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: #!usr/bin/env python3
  import sys
  import math
  import collections
  import numpy as np
  
  MOD = 10**9 + 7
  INF = float("inf")
  input = lambda: sys.stdin.readline().strip()
  
  sys.setrecursionlimit(10**8)
  
  
  def prime_factorization(n):
      """
      nを素因数分解したリストを返す。
      n >= 2
      """
      ans = []
      for i in range(2, int(math.sqrt(n) + 2)):
          if n % i == 0:
              while n % i == 0:
                  ans.append(i)
                  n //= i
      if n != 1:
          ans.append(n)
      return ans
  
  
  N = int(input())
  ans = 0
  primes = prime_factorization(N)
  prime_temp = []
  primes2 = prime_factorization(N - 1)
  List = []
  for i in range(2 ** (len(primes2))):
      temp = []
      for j in range(len(primes2)):
          prid = np.prod([primes2[j] if i & (1 << j) else 1 for j in range(len(primes2))])
          if prid != 1:
              List.append(prid)
  for i in range(2 ** (len(primes))):
      temp = []
      for j in range(len(primes)):
          if i & (1 << j):
              temp.append(primes[j])
          temp2 = 1
          if len(temp) > 1:
              for l in temp:
                  temp2 *= l
              prime_temp.append(temp2)
  List = list(set(List))
  a = collections.Counter(primes)
  prime_set = list(set(primes + prime_temp))
  for i in prime_set:
      if a[i] != 1:
          num = a[i]
          for j in range(2, num + 1):
              prime_set.append(i**j)
  for i in prime_set:
      temp = N
      while temp % i == 0:
          temp //= i
      if temp % i == 1:
          List.append(i)
  List = list(set(List))
  print(len(List) + 1 if N not in List else len(List))
  
problem_description: Statement
  
  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?
samples: [{"input": "6", "output": "3\n    \n\nThere are three choices of K in which N becomes 1 in the end: 2, 5, and 6.\n\nIn each of these choices, N will change as follows:\n\n  * When K=2: 6 \\to 3 \\to 1\n  * When K=5: 6 \\to 1\n  * When K=6: 6 \\to 1\n\n* * *"}, {"input": "3141", "output": "13\n    \n\n* * *"}, {"input": "314159265358", "output": "9"}]