#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, x = 0, y = 0, c = 0, max = 0, a[2] = {}, k, ans1;
  string s;
  char m;
  cin >> n >> k;
  cin >> s;
  m = 'a';
gt:
  max = 0;
  c = 0;
  x = 0;
  queue<int> q;
  for (i = 0; i < n; i++) {
    if (s[i] == m) {
      q.push(i);
      c++;
    }
    if (c > k || i == n - 1) {
      if ((i == n - 1 && c <= k) && i - x + 1 > max)
        max = i - x + 1;
      else if ((i != n - 1 || c > k) && i - x > max)
        max = i - x;
      x = q.front() + 1;
      q.pop();
      c--;
    }
  }
  if (m == 'a') {
    ans1 = max;
    m = 'b';
    goto gt;
  } else if (max > ans1)
    ans1 = max;
  cout << ans1;
  return (0);
}
