#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 7;
string s;
int ps[N];
int n, k;
bool valid(int x) {
  for (int i = 0; i + x <= n; i++)
    if (min(ps[i + x] - ps[i], x - ps[i + x] + ps[i]) <= k) return true;
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  cin >> s;
  for (int i = 0; i < n; i++) ps[i + 1] = ps[i] + (s[i] == 'a');
  int l = 1, r = n + 1;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (valid(mid))
      l = mid;
    else
      r = mid;
  }
  cout << l << "\n";
  return 0;
}
