The biggest border of the substring#1308

The biggest border of the substring

1 second
64 megabytes
Very easy

The border (also called verge or brink) of a string is any proper prefix of the string that is equal to a suffix of .

For example, the string S = \text{abaababaabaab} has two (non-empty) borders: and . The string S = \text{abaabaab} also has two borders: and , but the second border is overlapping. A string of length consisting of a repeated character, such as (or a^8), has n-1 borders. For S = a^8, its borders are: \text{a}, \text{aa}, \text{aaa}, \text{aaaa}, \text{aaaaa}, \text{aaaaaa}, \text{aaaaaaa}.

The notion of a "proper prefix" excludes the border that is equal to the entire string itself.

The length of a border is the number of characters it contains.

Let us generalize the problem. Suppose you want to compute the values of the largest borders for all prefixes for i = 1..n, and store them in the array .

Find the maximum value of the border in the array for all prefixes of .

Input

A string is given (|S| \leq 10^6).

Output

Print one number: the answer to the problem.

Examples

Example 1

Loading
Loading