#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
void files() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int solve(vector<int> d, int k) {
  int n = 0;
  int l = 0;
  int ans = 0;
  for (int i = 0; i < d.size(); i++) {
    if (d[i] == 0) {
      n++;
    }
    while (n > k) {
      if (d[l] == 0) {
        n--;
      }
      l++;
    }
    ans = max(ans, i - l + 1);
  }
  return ans;
}
int main() {
  fast();
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> d1, d2;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'a') {
      d1.push_back(1);
      d2.push_back(0);
    } else {
      d1.push_back(0);
      d2.push_back(1);
    }
  }
  cout << max(solve(d1, k), solve(d2, k));
  return 0;
}
