#include <bits/stdc++.h>
using namespace std;
long long dp[205][205][205];
int main() {
  long long n, k, i, j, l, mx = 0, one, two;
  string s, w;
  cin >> n >> k;
  cin >> s;
  cin >> w;
  s = "$" + s;
  n++;
  for (i = 0; i < 205; i++) {
    for (j = 0; j < 205; j++) {
      for (l = 0; l < 205; l++) {
        dp[i][j][l] = -10000000000;
      }
    }
  }
  dp[0][0][0] = 0;
  for (i = 1; i < n; i++) {
    for (j = 0; j <= i; j++) {
      for (l = 0; l <= min(i, k); l++) {
        if (s[i] == w[0]) {
          if (j >= 1) {
            one = dp[i - 1][j - 1][l];
          } else {
            one = -100000000;
          }
          dp[i][j][l] = max(one, dp[i][j][l]);
        }
        if (s[i] == w[1] && j >= (w[0] == w[1])) {
          dp[i][j][l] = max(dp[i][j][l], dp[i - 1][j - (w[0] == w[1])][l] + j -
                                             (w[0] == w[1]));
        }
        if (s[i] != w[0] && s[i] != w[1]) {
          dp[i][j][l] = dp[i - 1][j][l];
        }
        if (j >= 1 && l >= 1) {
          one = dp[i - 1][j - 1][l - 1];
        } else {
          one = -1000000000;
        }
        dp[i][j][l] = max(dp[i][j][l], one);
        if (l >= 1 && j >= (w[0] == w[1])) {
          two = dp[i - 1][j - (w[0] == w[1])][l - 1];
        } else {
          two = -1000000;
        }
        dp[i][j][l] = max(dp[i][j][l], two + j - (w[0] == w[1]));
        mx = max(mx, dp[i][j][l]);
      }
    }
  }
  cout << mx;
  return 0;
}
