#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  string a;
  cin >> n >> k;
  cin >> a;
  int f = 0, s = 0, as = 0, bs = 0, ans = 0;
  if (a[s] == 'a')
    as++;
  else
    bs++;
  for (;;) {
    if (as > k && bs > k) {
      while (as > k && bs > k) {
        if (a[f] == 'a')
          as--;
        else
          bs--;
        f++;
      }
    }
    ans = max(ans, s - f + 1);
    s++;
    if (s == n) break;
    if (a[s] == 'a')
      as++;
    else
      bs++;
  }
  cout << ans << '\n';
  return 0;
}
