#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long mod) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
long long modInverse(long long a, long long m) {
  long long m0 = m;
  long long y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long q = a / m;
    long long t = m;
    m = a % m, a = t;
    t = y;
    y = x - q * y;
    x = t;
  }
  if (x < 0) x += m0;
  return x;
}
long long binomial(long long n, long long k) {
  long long res = 1;
  if (k > n - k) k = n - k;
  for (long long i = 0; i < k; ++i) {
    res *= (n - i);
    res /= (i + 1);
  }
  return res;
}
const long long mod = 1e9 + 7;
const long long N = 1e5 + 9;
void doper() {}
long long n, k;
string s;
long long countans(long long x) {
  char t = 'a' + x;
  long long ans = 0;
  long long cnt = 0;
  long long j = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == t) cnt++;
    while (cnt > k) {
      if (s[j] == t) cnt--;
      j++;
    }
    ans = max(ans, abs(i - j + 1));
  }
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  doper();
  cin >> n >> k >> s;
  cout << max(countans(0), countans(1));
  return 0;
}
