Codeforces Round 122 (Div. 1)
E
Fibonacci Number
Codeforces
2900
原题
← D→
翻译中…

John Doe has a list of all Fibonacci numbers modulo $10^{13}$. This list is infinite, it starts with numbers $0$ and $1$. Each number in the list, apart from the first two, is a sum of previous two modulo $10^{13}$. That is, John's list is made from the Fibonacci numbers' list by replacing each number there by the remainder when divided by $10^{13}$.

翻译中…

John got interested in number $*f*$ ($0 ≤ *f* < 10^{13}$) and now wants to find its first occurrence in the list given above. Help John and find the number of the first occurence of number $*f*$ in the list or otherwise state that number $*f*$ does not occur in the list.

翻译中…

The numeration in John's list starts from zero. There, the $0$-th position is the number $0$, the $1$-st position is the number $1$, the $2$-nd position is the number $1$, the $3$-rd position is the number $2$, the $4$-th position is the number $3$ and so on. Thus, the beginning of the list looks like this: $0, 1, 1, 2, 3, 5, 8, 13, 21, ...$

翻译中…

Input

翻译中…

The first line contains the single integer $*f*$ ($0 ≤ *f* < 10^{13}$) — the number, which position in the list we should find.

翻译中…

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

翻译中…

Output

翻译中…

Print a single number — the number of the first occurrence of the given number in John's list. If this number doesn't occur in John's list, print -1.

翻译中…

样例

Input #1
13
Output #1
7
InputCopy OutputCopy
Input #2
377
Output #2
14
InputCopy OutputCopy
题目信息
题号
193E
时间限制
3 s
内存限制
256 MB
标签
暴力
数学
矩阵

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。