#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 100;
char str[maxn];
int a[maxn], b[maxn];
int main() {
  int n, k;
  while (~scanf("%d%d", &n, &k)) {
    scanf("%s", str + 1);
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 1; i <= n; i++) {
      if (str[i] == 'a') {
        a[i] = a[i - 1] + 1, b[i] = b[i - 1];
      } else {
        a[i] = a[i - 1], b[i] = b[i - 1] + 1;
      }
    }
    int l, r, mid, ans = 0;
    for (int i = 1; i <= n; i++) {
      l = i, r = n;
      while (l <= r) {
        mid = (l + r) / 2;
        if (a[mid] - a[i - 1] <= k || b[mid] - b[i - 1] <= k) {
          ans = max(ans, mid - i + 1);
          l = mid + 1;
        } else
          r = mid - 1;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
