#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n = 0, cost = 0, x = 0, beauty = 0, score = 0, i = 0, j = 0,
                k = 0;
  string input;
  cin >> n >> cost;
  cin >> input;
  for (k = 97; k <= 98; k++) {
    x = 0, score = 0, i = 0, j = 0;
    while (i < n) {
      while (5 == 5) {
        if ((int)input[j] == k) x++;
        score++;
        if (x == cost + 1 || j == n - 1) {
          if (x == cost + 1) {
            x--;
            score--;
          }
          if (beauty < score) beauty = score;
          if ((int)input[i] == k) {
            x--;
          }
          score--;
          i++;
          break;
        }
        j++;
      }
    }
  }
  cout << beauty;
}
