#include <bits/stdc++.h>
using namespace std;
long long n, k, h, mx = -1e18, m, dp1[100010], dp2[100010], l, r;
string a;
long long check(long long x) {
  for (int i = 1; i <= a.size(); i++) {
    if (i >= x) {
      if (min(dp1[i] - dp1[i - x], dp2[i] - dp2[i - x]) <= k) {
        return 1;
      }
    }
  }
  if (min(dp1[a.size()] - dp1[a.size() - x],
          dp2[a.size()] - dp2[a.size() - x]) <= k) {
    return 1;
  }
  return 0;
}
int main() {
  cin >> n >> k;
  cin >> a;
  for (int i = 1; i <= a.size(); i++) {
    if (a[i - 1] == 'b') {
      dp1[i]++;
    } else {
      dp2[i]++;
    }
    dp1[i] += dp1[i - 1];
    dp2[i] += dp2[i - 1];
  }
  dp1[n - n - 1] = 0;
  l = 0, r = n;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    if (check(mid) == 1) {
      l = mid;
    } else {
      r = mid;
    }
  }
  if (check(r) == 1) {
    l = r;
  }
  cout << l;
  return 0;
}
