#include <bits/stdc++.h>
using namespace std;
int n, k, a, b, x, y, i, j, m[100005], p[100005];
string s;
int main() {
  cin >> n >> k >> s;
  while (i < n) {
    m[i] = m[i - 1];
    if (s[i] == 'b') {
      m[i]++;
    }
    i++;
  }
  i = 0;
  while (i < n) {
    while (m[j] - m[i - 1] <= k && j < n) {
      a = max(a, j - i);
      j++;
    }
    i++;
  }
  i = 0;
  j = 0;
  while (i < n) {
    p[i] = p[i - 1];
    if (s[i] == 'a') {
      p[i]++;
    }
    i++;
  }
  i = 0;
  while (i < n) {
    while (p[j] - p[i - 1] <= k && j < n) {
      b = max(b, j - i);
      j++;
    }
    i++;
  }
  cout << max(a, b) + 1;
}
