#include <bits/stdc++.h>
using namespace std;
const int ans = 1e5 + 5;
int n, k;
char str[ans];
int yz[ans];
int main() {
  int s, e, cnt, temp;
  s = e = cnt = temp = 0;
  cin >> n >> k;
  cin >> str;
  for (int i = 0; i < n; i++) {
    if (str[i] == 'a')
      yz[i] = 1;
    else
      yz[i] = 0;
  }
  for (; s < n; s++) {
    while (e < n && temp + yz[e] <= k) temp += yz[e++];
    cnt = max(cnt, e - s);
    temp -= yz[s];
  }
  for (s = e = temp = 0; s < n; s++) {
    while (e < n && temp + !(yz[e]) <= k) temp += (!yz[e++]);
    cnt = max(cnt, e - s);
    temp -= (!yz[s]);
  }
  printf("%d\n", cnt);
  return 0;
}
