import Foundation

let number = readLine()!.componentsSeparatedByString(" ")

let N = Int(number[0])!

func divisors(N: Int) -> [Int] {
  var result: [Int] = []
  var i = 1
  while i * i <= N {
    if N % i == 0 {
      result.append(i)
      if i * i != N {
        result.append(N / i)
      }
    }
    i += 1
  }
  return result
}

let case1 = divisors(N)

var ans = 0
for num in case1 {
  if num == 1 {
    continue
  }
  var tmp = N
  while tmp % num == 0 {
    tmp /= num
  }
  if tmp % num == 1 {
    ans += 1
  }
}

ans += divisors(N-1).count - 1
print(ans)