Analyzing Bit (Yet Special) Strings#6437

Analyzing Bit (Yet Special) Strings

3 seconds
256 megabytes
Easy

Do you think that analyzing bit strings is easy? Well, that's only true if you are not in a dream. But now you are in a dream. Unexpected, right? Alas... I'm afraid this is not the dream you may have wished for. In your dream, you are faced with a long string of bits that you must deal with. And you clearly understand what you must do to escape this terrible dream right now: you have to find the best special string.

Fortunately, you remember that yesterday you read a book about the theory of special strings. You only managed to recall the strangest definition of special strings, which was as follows.

Suppose you have a bit string of length . Denote the bits of as T_1, T_2, \dots, T_n. Let A(i, j) and B(i, j) be the number of -bits and -bits, respectively, among T_i, T_{i+1}, \dots, T_j. A string is called special if for every between and , inclusive, both of the following conditions hold:

A(1, i) \ge B(1, i) \quad \text{and} \quad A(i, n) \le B(i, n).

However, not just any special string will do. You need the best special string. The dream is strange, and so are the rules for determining which of two strings is better. Let L_1 and L_2 be the lengths of two strings, and P_1 and P_2 the numbers of times they occur in the given string as substrings, respectively. Then, the first string is considered better than the second if L_1 \cdot P_1 > L_2 \cdot P_2.

So your task is simple... or is it? Find the best special string—a special string for which no other special string is better.

Input

The only line contains the string (2 \le |S| \le 2 \times 10^5), consisting of zeros and ones.

Output

The first line should contain the value of L \cdot P, where is the length of the best special string and is the number of its occurrences in as a substring. The second line should contain the best special string itself. If there are several best special strings, you may output any of them.

It is guaranteed that there exists at least one special string which is a substring of .

Examples

Example 1

Loading
Loading