#include <bits/stdc++.h>
using namespace std;
const int IINF = INT_MAX;
int n, k;
string s;
int sum[2][100100];
bool check(int sp, int type, int next) {
  if (next >= n) return false;
  int type_v = sum[type][next];
  if (sp - 1 >= 0) type_v -= sum[type][sp - 1];
  type_v += k;
  return type_v >= (next - sp + 1);
}
void compute() {
  if (s[0] == 'a') {
    ++sum[0][0];
  } else {
    ++sum[1][0];
  }
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 2; j++) sum[j][i] = sum[j][i - 1];
    if (s[i] == 'a')
      ++sum[0][i];
    else
      ++sum[1][i];
  }
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      int L = 0, R = n + 10;
      while (R - L) {
        int M = (L + R) / 2;
        if (check(i, j, M)) {
          L = M + 1;
        } else {
          R = M;
        }
      }
      int p = L - 1;
      if (p >= i) {
        maxi = max(maxi, p - i + 1);
      }
    }
  }
  cout << maxi << endl;
}
int main() {
  cin >> n >> k;
  cin >> s;
  compute();
  return 0;
}
