Subsequences of Length Two

题意翻译

## 题目描述 你将会得到两个字符串$s$ 和 $t$,并保证其中的字符都是小写拉丁字母。$t$ 的长度是 $2$。 一个操作代表你可以用一个任意的字符代替 $s$ 中任意一个字符(都是小写字母)。 你最多可以进行 $k$ 次操作,也可以不进行。 求进行替换之后最多可以在 $s$ 中出现多少个 $t$ 作为他的子序列。这里的子序列是指去掉原来字符串里的一些字符,不改变相对位置得到的串。 ## 输入格式 第一行包括两个数 $n$,$k$ ($2\le n,k\le 200$)。 接下来的两行分别是 $s$,$t$。 ## 输出格式 输出一行一个数,表示最多用 $k$ 次操作之后,出现子序列是 $t$ 的最多的次数。

题目描述

You are given two strings $ s $ and $ t $ consisting of lowercase Latin letters. The length of $ t $ is $ 2 $ (i.e. this string consists only of two characters). In one move, you can choose any character of $ s $ and replace it with any lowercase Latin letter. More formally, you choose some $ i $ and replace $ s_i $ (the character at the position $ i $ ) with some character from 'a' to 'z'. You want to do no more than $ k $ replacements in such a way that maximizes the number of occurrences of $ t $ in $ s $ 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 $ n $ and $ k $ ( $ 2 \le n \le 200 $ ; $ 0 \le k \le n $ ) — the length of $ s $ and the maximum number of moves you can make. The second line of the input contains the string $ s $ consisting of $ n $ lowercase Latin letters. The third line of the input contains the string $ t $ consisting of two lowercase Latin letters.

输出格式


Print one integer — the maximum possible number of occurrences of $ t $ in $ s $ as a subsequence if you replace no more than $ k $ characters in $ s $ optimally.

输入输出样例

输入样例 #1

4 2
bbaa
ab

输出样例 #1

3

输入样例 #2

7 3
asddsaf
sd

输出样例 #2

10

输入样例 #3

15 6
qwertyhgfdsazxc
qa

输出样例 #3

16

输入样例 #4

7 2
abacaba
aa

输出样例 #4

15

说明

In the first example, you can obtain the string "abab" replacing $ s_1 $ with 'a' and $ s_4 $ with 'b'. Then the answer is $ 3 $ . In the second example, you can obtain the string "ssddsdd" and get the answer $ 10 $ . In the fourth example, you can obtain the string "aaacaaa" and get the answer $ 15 $ .