PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000182. Chia hoặc trừ (Division or Subtraction)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chia hoặc trừ (Division or Subtraction)

Division or Subtraction

Source: AtCoder

Version: Phuoc Hung OJ Extended

Problem Statement

Given a positive integer NN, choose an integer KK with 2≤K≤N2\le K\le N. Initially x=Nx=N. While x≥Kx\ge K, if xx is divisible by KK, replace xx with x/Kx/K; otherwise replace it with x−Kx-K. Count the choices of KK for which the final value of xx is exactly 11.

Input

The input contains NN.

Output

Print the number of valid values KK.

Subtasks

  • Subtask 1 (20 points): 2≤N≤10002 \le N \le 1000.

  • Subtask 2 (30 points): 2≤N≤1000000002 \le N \le 100000000.

  • Subtask 3 (50 points): 2≤N≤10000000000002 \le N \le 1000000000000.

Examples

Example 1

Input

6

Output

3

Explanation

The valid choices are K=2,5,6K=2,5,6. The sequences of values are 6→3→16\to3\to1, 6→16\to1, and 6→16\to1, respectively.

Example 2

Input

3141

Output

13

Explanation

Thirteen choices of KK terminate at 11; it is sufficient to test the divisors of NN and N−1N-1.

Example 3

Input

314159265358

Output

9

Explanation

For this large input, exactly nine valid divisors/candidates lead to the final value 11.