One String No Trouble

3.7

81 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

A string s is called a good string if and only if two consecutive letters are not the same. For example, abcab and  cda are good while abaa and accba are not.

You are given a string s. Among all the good substrings of s ,print the size of the longest one.

Input format

A single line that contains a string s (1|s|2105).

Output format

Print an integer that denotes the size of the longest good substring of s.

Sample Input
ab
Sample Output
2
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The complete string is good so the answer is 2.

Editor Image

?