#include <bits/stdc++.h>
using namespace std;
const long long OO = 1e18;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
void fast() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
int n, k;
int a[(int)1e5 + 2];
int b[(int)1e5 + 2];
string s;
int main() {
  fast();
  cin >> n >> k;
  cin >> s;
  for (int i = 0; i < (int)(n); ++i) {
    a[i + 1] = (s[i] == 'a');
    b[i + 1] = (s[i] == 'b');
    a[i + 1] += a[i];
    b[i + 1] += b[i];
  }
  long long mx = 0;
  for (int i = 0; i < (int)(n); ++i) {
    long long lo = i + 1, hi = n;
    while (lo < hi) {
      long long md = lo + (hi - lo + 1) / 2;
      if (b[md] - b[i] <= k)
        lo = md;
      else
        hi = md - 1;
    }
    mx = max(mx, lo - i);
  }
  for (int i = 0; i < (int)(n); ++i) {
    long long lo = i + 1, hi = n;
    while (lo < hi) {
      long long md = lo + (hi - lo + 1) / 2;
      if (a[md] - a[i] <= k)
        lo = md;
      else
        hi = md - 1;
    }
    mx = max(mx, lo - i);
  }
  cout << mx << endl;
  return 0;
}
