Devil's Sequence

Compute x_n = (x_{n-1}+x_{n-2})/2 with x_0=0, x_1=1, and count consecutive leading 6s after the decimal point.

Medium6MathNumber theoryImplementationNo attempts yetTime limit0.5sMemory limit64 MB

Problem

The devil's sequence xx is defined as follows.

x0=0,x1=1,xn=xn1+xn22(n2)x_0 = 0, \qquad x_1 = 1, \qquad x_n = \frac{x_{n-1} + x_{n-2}}{2} \quad (n \ge 2)

For example, x10=0.666015625x_{10} = 0.666015625, and three sixes run from the first digit after the decimal point.

Given nn, write a program that finds how many sixes run consecutively from the first digit after the decimal point of xnx_n.

Input

The first line contains an integer nn. (2n1000002 \le n \le 100000)

Output

Print the number of consecutive sixes starting at the first digit after the decimal point of xnx_n. Print 0 if that digit is not a six.