Serrated sequence
The sequence is called 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.
Serrated subsequence figures assume any serrated sequence of consecutive digits in the resulting sequence.
Input
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 10^6, and their number is not greater than 5·10^3.
Output
The output file a single number - the answer of the problem.