#P1409F. Subsequences of Length Two
Subsequences of Length Two
Description
You are given two strings and consisting of lowercase Latin letters. The length of is (i.e. this string consists only of two characters).
In one move, you can choose any character of and replace it with any lowercase Latin letter. More formally, you choose some and replace (the character at the position ) with some character from 'a' to 'z'.
You want to do no more than replacements in such a way that maximizes the number of occurrences of in as a subsequence.
Recall that a subsequence is a sequence that can be derived from the given sequence by deleting zero or more elements without changing the order of the remaining elements.
The first line of the input contains two integers and (; ) — the length of and the maximum number of moves you can make. The second line of the input contains the string consisting of lowercase Latin letters. The third line of the input contains the string consisting of two lowercase Latin letters.
Print one integer — the maximum possible number of occurrences of in as a subsequence if you replace no more than characters in optimally.
Input
The first line of the input contains two integers and (; ) — the length of and the maximum number of moves you can make. The second line of the input contains the string consisting of lowercase Latin letters. The third line of the input contains the string consisting of two lowercase Latin letters.
Output
Print one integer — the maximum possible number of occurrences of in as a subsequence if you replace no more than characters in optimally.
Note
In the first example, you can obtain the string "abab" replacing with 'a' and with 'b'. Then the answer is .
In the second example, you can obtain the string "ssddsdd" and get the answer .
In the fourth example, you can obtain the string "aaacaaa" and get the answer .