#P6948. Substring

    ID: 5805 远端评测题 1000ms 64MiB 尝试: 0 已通过: 0 难度: (无) 上传者: 标签>2021“MINIEYE杯”中国大学生算法设计超级联赛-热身赛(2021湘潭全国邀请赛-重现)

Substring

Problem Description

You are given a string $S[1..N]$ containing only lowercase letters. Now you need to find the longest substring $S[l..r]$ such that every letter (`a` to `z`) appears no more than $K$ times in the substring. You just need to output the length ($r-l+1$) of the longest substring.

Input

There are multiple test cases.

Each test case contains one integer $K$ ($1\leq K \leq N$) and one string $S$ in one line.

It's guaranteed that the sum of lengths of the input strings is no more than $4 \times 10^5$.

Output

For each test case, print one integer in one line, denoting the length of the longest substring.

1 abcabcabc 2 abcabcabc 2 aaabbbccc
3 6 4