#include <bits/stdc++.h>
using namespace std;
char s[100005];
int n, t;
int ruler(char aim) {
  int left = 0, ct = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == aim) {
      if (ct < t) {
        ct++;
      } else {
        while (left < i && s[left] != aim) {
          left++;
        }
        left++;
      }
    }
    cnt = max(cnt, i - left + 1);
  }
  return cnt;
}
int main() {
  scanf("%d%d", &n, &t);
  scanf("%s", s);
  printf("%d\n", max(ruler('a'), ruler('b')));
}
