#include <bits/stdc++.h>
using namespace std;
char s[100010];
int n, k;
int suma[100010], sumb[100010];
int check(int x) {
  for (int i = x; i <= n; i++)
    if (suma[i] - suma[i - x] <= k || sumb[i] - sumb[i - x] <= k) return true;
  return false;
}
int main(void) {
  scanf("%d%d", &n, &k);
  getchar();
  gets(s + 1);
  for (int i = 1; i <= n; i++) {
    suma[i] = suma[i - 1];
    sumb[i] = sumb[i - 1];
    if (s[i] == 'a')
      suma[i]++;
    else
      sumb[i]++;
  }
  int L = 0, R = n, ans = 0;
  while (L <= R) {
    int mid = (L + R) >> 1;
    if (check(mid)) {
      ans = mid;
      L = mid + 1;
    } else {
      R = mid - 1;
    }
  }
  cout << ans;
  return 0;
}
