#48Medium
Index of a Fibonacci number
Time: 1 s · Memory: 256 MB
- Loops
Statement
The Fibonacci numbers are , , , that is
You are given a natural number (). If is a Fibonacci number, print its index (), otherwise print .
Input format
A single integer ().
Output format
A single integer — or .
Examples
Input
13
Output
7
Input
7
Output
0
Note
Generate Fibonacci numbers one by one while the current one is less than — a while loop. If it equals when the loop stops, you found it. In the first example ; lies between and , so the answer is .
Numbers up to need long long / int64.
