#include <bits/stdc++.h>
using namespace std;
const int MX = 205;
long long n;
string str, pat;
long long dp[MX][MX][MX];
long long func(long long pos, long long rem, long long cnt1) {
  if (pos >= n) return 0;
  long long &r = dp[pos][rem][cnt1];
  if (r != -1) return r;
  r = cnt1 * (str[pos] == pat[1]) +
      func(pos + 1, rem, cnt1 + (str[pos] == pat[0]));
  if (rem) {
    char ch = pat[0];
    r = max(r, cnt1 * (ch == pat[1]) +
                   func(pos + 1, rem - 1, cnt1 + (ch == pat[0])));
    ch = pat[1];
    r = max(r, cnt1 * (ch == pat[1]) +
                   func(pos + 1, rem - 1, cnt1 + (ch == pat[0])));
  }
  return r;
}
int main() {
  long long i, j, k;
  cin >> n >> k;
  cin >> str >> pat;
  memset(dp, -1, sizeof dp);
  cout << func(0, k, 0) << endl;
}
