Power Hungry Cows
题号:NC51040
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 32 M,其他语言64 M
64bit IO Format: %lld

题目描述

FJ's cows would like to be able to compute integer powers P of numbers very quickly, but need your help. Because they're going to be computing powers of very large numbers, they can only keep around two work variables for intermediate results.

The first of those work variables is initialized to the number (denoted x) for which they are calculating the power; the other is initialized to 1. The cows can both multiply and divide any pair of the work variables and store the result in any work variable, but all results are stored as integers.

For example, if they want to compute , one way to perform the calculation is:
WV1 WV2

Start: x 1
Multiply first by first, store in second: x
Multiply second by second: x
Multiply second by second: x
Multiply second by second: x
Multiply second by second: x
Divide second by first: x

Thus, can computed in six operations. Given the power to be computed and the the number of work variables, find the minimum number of operations to calculate the power.

输入描述:

A single line with one integer: P.

输出描述:

A single line with a single integer that is the minimum number of operations it requires to compute the power.
示例1

输入

复制
31

输出

复制
6