#C9686. Maximum Distinct Characters in a Substring

    ID: 53806 Type: Default 1000ms 256MiB

Maximum Distinct Characters in a Substring

Maximum Distinct Characters in a Substring

You are given a string s consisting of lowercase English letters and an integer k. Your task is to determine the maximum number of distinct characters present in any contiguous substring of s with length k.

We denote the string as \( s \) and the integer as \( k \). For each substring \( s[i:i+k] \) (where \( 0 \leq i \leq |s|-k \)), compute the number of distinct characters and output the maximum value found among all these substrings.

Example:

Input:
abcda
3

Output: 3

</p>

inputFormat

The input is given via standard input (stdin) and consists of two lines:

  • The first line contains the string \( s \) which consists only of lowercase English letters.
  • The second line contains the integer \( k \), representing the length of the substring to consider.

outputFormat

Output a single integer to standard output (stdout) representing the maximum number of distinct characters found in any substring of length \( k \).

## sample
abcda
3
3