题目描述
Problem Description
A niconico string is a string that consists of 25 repeated zero or more times. For example, 25, 252525, and an empty string are niconico strings, but 123 and 225 are not.
The niconico level of a string $ S $ is defined as the length of the longest niconico string that is a contiguous substring of $ S $. For example, the niconico levels of 52525, 25025, and 12151 are $ 4 $, $ 2 $, and $ 0 $ respectively.
Niwango-kun has a string $ T $ consisting of digits 0 to 9 and ?. He wants to replace each ? with any digit to form a string $ T' $ consisting only of digits. Determine the maximum niconico level that Niwango-kun can achieve with the string $ T' $.
Input Format
The input is given from the standard input in the following format:
$ T $
Output Format
Output the maximum niconico level that Niwango-kun can achieve with the string $ T' $ in one line.
Sample Input and Output
Sample Input #1
12??567890
Sample Output #1
4
Sample Input #2
65?5?4?
Sample Output #2
2
Sample Input #3
314159265358979
Sample Output #3
0
Sample Input #4
2???5????
Sample Output #4
8
Sample Input #5
52
Sample Output #5
0
Notes/Hints
Constraints
- $1 \leq |T| \leq 10^5$
- Each character in $ T $ is either a digit from
0to9or?.
Sample Explanation 1
By replacing the ? with 5 and 2 in order, the string becomes 1252567890, where the substring from the 2nd to the 5th character is 2525, achieving a niconico level of $ 4 $.
Sample Explanation 3
A string that does not contain 25 at all has a niconico level of $ 0 $.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分