#K43962. Longest Substring with At Most Two Distinct Characters

    ID: 27426 Type: Default 1000ms 256MiB

Longest Substring with At Most Two Distinct Characters

Longest Substring with At Most Two Distinct Characters

You are given a string s. Your task is to determine the length of the longest substring that contains at most two distinct characters. The substring must consist of contiguous characters from s.

For example, if s = "eceba", the longest valid substring is "ece" which has a length of 3.

Note: The input string contains only lowercase English letters.

inputFormat

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

Input format: A single line read from standard input.

outputFormat

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

Output format: Print the result to standard output.

## sample
eceba
3