#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long n, k;
string a, b;
long long dp[210][210][210];
long long solve(long long p1, long long p2, long long step) {
  if (step > k) return INT_MIN;
  if (p1 == a.size()) return 0;
  long long &ans = dp[p1][p2][step];
  if (ans != -1) return ans;
  ans = 0;
  ans = max(ans, solve(p1 + 1, p2 + (a[p1] == b[0]), step) +
                     (a[p1] == b[1] ? p2 : 0));
  ans = max(ans, solve(p1 + 1, p2 + 1, step + 1) + (b[0] == b[1] ? p2 : 0));
  ans = max(ans, solve(p1 + 1, p2 + (b[0] == b[1]), step + 1) + p2);
  return ans;
}
void solve() {
  memset(dp, -1, sizeof dp);
  cin >> n >> k >> a >> b;
  cout << solve(0, 0, 0) << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t = 1;
  while (t--) solve();
  return 0;
}
