atcoder#ABC161F. [ABC161F] Division or Subtraction

[ABC161F] Division or Subtraction

Score : 600600 points

Problem Statement

Given is a positive integer NN.

We will choose an integer KK between 22 and NN (inclusive), then we will repeat the operation below until NN becomes less than KK.

  • Operation: if KK divides NN, replace NN with N/KN/K; otherwise, replace NN with NKN-K.

In how many choices of KK will NN become 11 in the end?

Constraints

  • 2N10122 \leq N \leq 10^{12}
  • NN is an integer.

Input

Input is given from Standard Input in the following format:

NN

Output

Print the number of choices of KK in which NN becomes 11 in the end.

6
3

There are three choices of KK in which NN becomes 11 in the end: 22, 55, and 66.

In each of these choices, NN will change as follows:

  • When K=2K=2: 6316 \to 3 \to 1
  • When K=5K=5: 616 \to 1
  • When K=6K=6: 616 \to 1
3141
13
314159265358
9