#include <bits/stdc++.h>
struct pairhash {
  template <typename T, typename U>
  std::size_t operator()(const std::pair<T, U>& x) const {
    return std::hash<T>()(x.first) ^ std::hash<U>()(x.second);
  }
};
long long compute_gcd(long long a, long long b) {
  if (b == 0) return a;
  return compute_gcd(b, a % b);
}
unsigned long long compute_lcm(unsigned long long a, unsigned long long b) {
  unsigned long long gcd = compute_gcd(a, b);
  return a / gcd * b;
}
int solve(std::string const& data, int k, char a) {
  std::deque<int> bs;
  int window_start = 0;
  int result = 0;
  for (int i = 0; i < data.size(); ++i) {
    if (data[i] != a) {
      bs.push_back(i);
    } else {
      while (bs.size() > k) {
        window_start = bs.front() + 1;
        bs.pop_front();
      }
      result = std::max(i - window_start + 1, result);
    }
  }
  if (bs.size() <= k) {
    result = std::max<int>(data.size() - window_start, result);
  }
  return result;
}
int main() {
  long long n, k;
  std::cin >> n >> k;
  std::string data;
  std::cin >> data;
  std::cout << std::max(solve(data, k, 'a'), solve(data, k, 'b'));
  return 0;
}
