193_E. Fibonacci Number
John Doe has a list of all Fibonacci numbers modulo 1013. 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 1013. That is, John's list is made from the Fibonacci numbers' list by replacing each number there by the remainder when divided by 1013. 

John got interested in number f (0 ≤ f < 1013) 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 < 1013) — 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.

Examples

Input

13


Output

7


Input

377


Output

14
```python
low_n = 1000
high_m = 15000
limit = int(10 ** 13)

f = int(input())
inputList = []

def customFunction(i):
    if i == 0:
        return (0, 1)
    a, b = customFunction(i >> 1)
    a, b = ((2 * a * b - a * a) % low_n, (b * b + a * a) % low_n)

    if i & 1:
        a, b = (b % low_n, (a + b) % low_n)
    return (a, b)

i = 0
while i < high_m:
	if customFunction(i)[0] == f % low_n:
		inputList.append(i)
	i += 1

while low_n < limit:
    low_n *= 10

    tempList = []
    for i in inputList:
        for j in range(10):
            if customFunction(i + j * high_m)[0] == f % low_n:
                tempList.append(i + j * high_m)
    inputList = tempList
    high_m *= 10

    if inputList == []:
        break

if inputList == []:
    print(-1)
else:
    inputList = sorted(inputList)
    print(inputList[0])

```