The text file consists of no more than 10
6 characters and contains only uppercase Latin letters (
ABC…Z
). The text is divided into lines of various lengths. It is necessary to find the string in which the sequence of letters
AA
occurs most often. If there are several such lines, you need to take the one that was encountered earlier in the file. Determine in this string the length of the longest subsequence in which there are no two adjacent identical letters. Write down the length of this subsequence in your answer.
Example
Source file:
AAAABABC
ZZAAAACZ
QRAAUT
In this example, the sequence AA occurs 3 times in the first and second lines, in the third – 1. We take the first line, because it is in the file before. This line contains the longest subsequence that does not contain two adjacent identical letters
ABABC, its length is 5. In the answer for this example, write
5
.
Assignment file