Degree#195

Degree

1 second
64 megabytes
Hard

The interpreter for the programming language Base_ABC can perform assignments of the form A := B * C (where A, B, and C are variable names), but it cannot directly compute exponentiation to a natural power. Therefore, computing an expression of the form A^N must be replaced by a sequence of multiplication commands.

For example, the command X := A^5 can be rewritten as the following sequence of three assignments, each involving one multiplication:

R_1 := A * A
R_2 := A * R_1
X := R_1 * R_2

Given , determine the minimum number of assignment commands, each involving one multiplication, needed to compute A^N.

Input

The input contains the integer (2 \leq N \leq 2000).

Output

Output a single integer — the answer to the problem.

Examples

Example 1

Loading
Loading