#include <bits/stdc++.h>
using namespace std;
const int SIZE = (int)201;
int dp[SIZE][SIZE][SIZE];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, k, ans = 0;
  string s, t;
  cin >> n >> k;
  cin >> s >> t;
  for (int i = 0; i < n + 1; i += 1)
    for (int j = 0; j < k + 1; j += 1)
      for (int h = 0; h < n + 1; h += 1) dp[i][j][h] = -(int)1e5;
  dp[0][0][0] = 0;
  for (int i = 0; i < n; i++) {
    for (int k1 = 0; k1 <= k; k1++) {
      for (int j = 0; j <= n; j++) {
        if (dp[i][k1][j] == -(int)1e5) {
          continue;
        }
        int a1 = s[i] == t[0];
        int a2 = s[i] == t[1];
        int a3 = t[1] == t[0];
        dp[i + 1][k1][j + a1] =
            max(dp[i + 1][k1][j + a1], dp[i][k1][j] + a2 * j);
        if (k1 < k)
          dp[i + 1][k1 + 1][j + 1] =
              max(dp[i + 1][k1 + 1][j + 1], dp[i][k1][j] + a3 * j);
        if (k1 < k)
          dp[i + 1][k1 + 1][j] = max(dp[i + 1][k1 + 1][j], dp[i][k1][j] + j);
      }
    }
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= k; j++) {
      ans = max(ans, dp[n][j][i]);
    }
  }
  cout << ans << "\n";
  return 0;
}
