Jonathan is given a string containing solely lowercase english letters. He is asked to perform the two following operations in order exactly once:
- Remove a substring of length up to (inclusive) from the string.
- Remove up to (inclusive) characters from the remaining string.
Let be the number of
a's in the resultant string, be the number of
b's, etc. Jonathan's goal is to minimize after performing the two operations. What is the minimum possible value?
Python users are recommended to use PYPY over CPython. There is a significant performance increase.
The first line will contain the string . will only contain lowercase english letters.
The second line will contain two integers, .
Output the minimum possible value of for Jonathan.
Subtask 1 [30%]
Subtask 2 [70%]
No further constraints.
Sample Input 1
abcdefghijkllllll 0 5
Sample Output 1
Sample Input 2
rimuruclasher 3 2
Sample Output 2