Problems
Serrated sequence
Serrated sequence
The sequence is called \textit{serrated}, if every member of this sequence is not located at its end is less than or greater than both its neighbors. For the extreme numbers, this condition must be satisfied for the corresponding elements of the existing order.
Our task - for a given number sequence consisting of a non-negative integers, define the maximum length of the serrated subsequence obtained by writing out a row of numbers that make up the septenary significance of these numbers.
\textit{Serrated subsequence} figures assume any serrated sequence of consecutive digits in the resulting sequence.
\InputFile
The input file are decimal values of the sequence in the original order. It is guaranteed that the members of the sequence can not exceed \textbf{10^6}, and their number is not greater than \textbf{5·10^3}.
\OutputFile
The output file a single number - the answer of the problem.
Input example #1
3 4 5 6 2 5 3 4 70
Output example #1
9