#include <bits/stdc++.h>
using namespace std;
int main() {
  int cnt, i, n, k, ans = 0, v = 0, y = 0, c = 0, d;
  scanf("%d", &n);
  scanf("%d", &k);
  char x[100005];
  scanf("%s", x);
  for (i = 0; i < n; i++) {
    if (x[i] == 'a')
      v++;
    else
      y++;
    d = i;
    while (min(v, y) > k) {
      if (x[c] == 'a') {
        v--;
        c++;
      } else {
        y--;
        c++;
      }
    }
    ans = max(ans, d - c);
  }
  printf("%d", ans + 1);
  printf("\n");
  return 0;
}
