#include <bits/stdc++.h>
using namespace std;
long long int n, kk;
string s, t;
long long int dp[202][202][202];
long long int solve(long long int i, long long int j, long long int k) {
  if (i == n) return dp[i][j][k] = 0;
  if (dp[i][j][k] != -1) return dp[i][j][k];
  long long int ret = 0;
  if (s[i] == t[0])
    ret = max(ret, solve(i + 1, j + 1, k));
  else
    ret = max(ret, solve(i + 1, j, k));
  if (s[i] == t[1])
    ret = max(ret, j + solve(i + 1, j, k));
  else
    ret = max(ret, solve(i + 1, j, k));
  if (k < kk) {
    ret = max(ret, solve(i + 1, j + 1, k + 1));
    ret = max(ret, j + solve(i + 1, j, k + 1));
  }
  return dp[i][j][k] = ret;
}
long long int solve2() {
  long long int ans = 0;
  for (auto const &i : s)
    if (i == t[0]) ans++;
  ans = min(ans + kk, n);
  return (ans * (ans - 1)) >> 1;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> kk >> s >> t;
  memset(dp, -1, sizeof(dp));
  if (t[0] == t[1])
    cout << solve2() << endl;
  else
    cout << solve(0, 0, 0) << endl;
  return 0;
}
