#C13067. Longest Substring with At Most Two Distinct Characters

    ID: 42564 Type: Default 1000ms 256MiB

Longest Substring with At Most Two Distinct Characters

Longest Substring with At Most Two Distinct Characters

Given a string s consisting of lowercase letters only, your task is to determine the length of the longest substring that contains at most two distinct characters.

You are allowed to choose any contiguous substring of s such that it contains no more than two unique characters. The answer is the maximum length among all such substrings found in s.

For example, when s = "eceba", there are substrings like "ece" which contain only 'e' and 'c', and its length is 3. Hence, the output is 3.

inputFormat

The input consists of a single line containing the string s.

outputFormat

Output a single integer representing the length of the longest substring of s that contains at most two distinct characters.

## sample
0