#155Easy
Distinct split
Time: 1 s · Memory: 256 MB
- Prefix sums
Statement
Let be the number of distinct letters in string . Split a string of lowercase Latin letters into two non-empty strings and () so that is as large as possible. Find this maximum value.
Input format
The first line contains (). The second line contains a string of lowercase Latin letters.
Output format
A single number — the maximum value of .
Examples
Input
7 abcabcd
Output
7
Input
4 aazz
Output
3
Note
Recounting both parts for every split point is . Instead compute — the number of distinct letters among the first (prefix) and — the number of distinct letters from position to the end (suffix). Both arrays take one pass each, and the answer is .
In the first example abc + abcd: .
Source: Codeforces, problem 1791D.
