#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, l;
  cin >> n >> l;
  string s;
  cin >> s;
  long long dp[n + 1], a = 0, b = 0, k = 0;
  dp[0] = 1;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'a')
      a++;
    else
      b++;
    if (min(a, b) <= l)
      dp[i + 1] = a + b;
    else {
      dp[i + 1] = dp[i];
      a -= (s[k] == 'a');
      b -= (s[k] == 'b');
      k++;
    }
  }
  cout << dp[n];
  return 0;
}
