#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 14;
int sp[MAX];
char sir[MAX];
int numara(int i, int j) { return sp[j] - sp[i - 1]; }
int main() {
  int n, k;
  cin >> n >> k;
  cin >> (sir + 1);
  for (register int i = 1; i <= n; ++i) {
    if (sir[i] == 'a') {
      sp[i] = sp[i - 1] + 1;
    } else {
      sp[i] = sp[i - 1];
    }
  }
  int best = 0;
  for (register int i = 1; i <= n; ++i) {
    int st = 1;
    int dr = i;
    int sol = i;
    while (st <= dr) {
      int mij = (st + dr) >> 1;
      if (numara(mij, i) <= k) {
        sol = mij;
        dr = mij - 1;
      } else {
        st = mij + 1;
      }
    }
    best = max(best, i - sol + 1);
  }
  for (register int i = 1; i <= n; ++i) {
    if (sir[i] == 'a') {
      sp[i] = sp[i - 1];
    } else {
      sp[i] = sp[i - 1] + 1;
    }
  }
  for (register int i = 1; i <= n; ++i) {
    int st = 1;
    int dr = i;
    int sol = i;
    while (st <= dr) {
      int mij = (st + dr) >> 1;
      if (numara(mij, i) <= k) {
        sol = mij;
        dr = mij - 1;
      } else {
        st = mij + 1;
      }
    }
    best = max(best, i - sol + 1);
  }
  cout << best << '\n';
  return 0;
}
