#P2090. 数字对

数字对

Description

For a number pair (a,b)(a, b), in one operation we can transform it into (a+b,b)(a+b, b) or (a,a+b)(a, a+b).

Given a positive integer nn, find the minimum number of operations to transform the pair (1,1)(1, 1) into a pair in which at least one number is nn.

Input Format

One line containing a positive integer nn.

Output Format

One integer representing the answer.

5
3

Hint

Sample explanation:

(1,1)(1,2)(3,2)(5,2)(1,1)  \to  (1,2)  \to  (3,2)  \to  (5,2)

For 30%30\% of the testdata, 1n10001 \le n \le 1000.

For 60%60\% of the testdata, 1n200001 \le n \le 20000.

For 100%100\% of the testdata, 1n1061 \le n \le 10^6.

Translated by ChatGPT 5