Just Laughter
InterviewTime limit2sMemory limit1024 MB
Find the length of the longest substring made of alternating letters a and h in a string of up to 100,000 lowercase letters.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Statement
Kolobok likes to laugh a lot. Before meeting a potential opponent, Lisa decides to study his laughter.
Lisa considers laughter to be a sequence of alternating letters a and h. For example, ahahaha, hah, and a are laughter, while abacaba and hh are not.
Kolobok talks very fast, so all of his words run together into one long string. Lisa has a transcript of Kolobok's conversation and wants to know how long he can laugh without stopping. She asks you to find the length of the longest laughter in the conversation.
Input
The first line contains one natural number (), the length of the transcript. The second line contains a string of lowercase Latin letters, the transcript of Kolobok's conversation.
Output
Print one number, the length of the longest laughter in the conversation.