#include <bits/stdc++.h>
using namespace std;
const int mxN = 201;
const int inf = INT_MAX;
int n, k;
string s, t;
int memo[mxN][mxN][mxN];
int dp(int pos, int apps, int changes) {
  if (changes < 0) return -inf;
  if (pos >= n) return 0;
  if (memo[pos][apps][changes] == -1) {
    memo[pos][apps][changes] = max(
        dp(pos + 1, apps + (s[pos] == t[0]), changes) + (s[pos] == t[1]) * apps,
        max(dp(pos + 1, apps + 1, changes - 1) + (t[0] == t[1]) * apps,
            dp(pos + 1, apps + (t[1] == t[0]), changes - 1) + apps));
  }
  return memo[pos][apps][changes];
}
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(memo, -1, sizeof(memo));
  cin >> n >> k >> s >> t;
  cout << dp(0, 0, k) << endl;
}
