let rec aux n k =
  if n mod k = 0
  then aux (n / k) k
  else n

let rec solve n k ans =
  if n < k * k
  then ans
  else
    solve n (k + 1) @@
    ans +
    if n mod k = 0
    then (if aux n k mod k = 1 then 1 else 0) + (if aux n (n / k) mod (n / k) = 1 then 1 else 0)
    else if (n - 1) mod k = 0
    then 1 + (if n - 1 = k * k || n mod ((n - 1) / k) = 0 then 0 else 1)
    else 0
let solve n = solve n 2 2

let () = Printf.printf "%d\n" @@ Scanf.scanf "%d" solve