Consecutive repeated words P23001


Statement
 

pdf   zip

Given a sequence of words, print the length of the longest consecutive subsequence that only contains the first word. That is, if the sequence is s1,,sns_1, \dots, s_n, print max{ji+1:1ijnsi=si+1==sj1=sj=s1}.\mbox{max}\{j - i + 1 : 1 \le i \le j \le n \wedge s_i = s_{i+1} = \dots = s_{j-1} = s_j = s_1 \} .

Input

Input consists of a non-empty sequence of words.

Output

Print the number of words of the longest consecutive subsequence that only contains the first word.

Public test cases
  • Input

    hello bye bye hello hello hello bye hello hello
    

    Output

    3
    
  • Input

    one  two  two  three  three  three
    

    Output

    1
    
  • Information
    Author
    Salvador Roura
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++ Java Python
    User solutions
    C C++ Java Python