#include <bits/stdc++.h>
using namespace std;
int i, j, k;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int len, ch;
  string s;
  cin >> len >> ch;
  cin >> s;
  int suma[len + 1];
  suma[0] = 0;
  int sumb[len + 1];
  sumb[0] = 0;
  for (int i = 0; i < s.length(); i++) {
    suma[i + 1] = suma[i];
    sumb[i + 1] = sumb[i];
    if (s[i] == 'a')
      suma[i + 1]++;
    else
      sumb[i + 1]++;
  }
  int l, r, ans = 0;
  for (int i = 0; i < s.length(); i++) {
    l = i;
    int ans1 = 0, ans2 = 0;
    r = s.length() - 1;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (suma[mid + 1] - suma[i] <= ch) {
        l = mid + 1;
        ans1 = mid;
      } else
        r = mid - 1;
    }
    l = i;
    r = s.length() - 1;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (sumb[mid + 1] - sumb[i] <= ch) {
        l = mid + 1;
        ans2 = mid;
      } else
        r = mid - 1;
    }
    ans = max(ans, max(ans1 - i + 1, ans2 - i + 1));
  }
  cout << ans << "\n";
  return 0;
}
