#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
signed main(void) {
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<vector<long long> > a(26);
  for (long long i = 0; i < (n); i++) {
    a[s[i] - 'a'].push_back(i);
  }
  if (k == 1) {
    long long ans = 0;
    for (long long i = 0; i < (26); i++) ans = max(ans, (long long)a[i].size());
    cout << ans << endl;
    return 0;
  }
  long long ok = 0, ng = n + 2;
  while (ng - ok > 1) {
    long long mid = (ok + ng) / 2;
    bool c = false;
    for (long long i = 0; i < (26); i++)
      if (a[i].size() >= k * mid) {
        long long cnt = 0;
        long long j = 0, len = 1;
        while (j < a[i].size()) {
          if (a[i][j] == a[i][j + 1] - 1) {
            len++;
          } else {
            len = 1;
          }
          if (len == k) {
            cnt++;
            j++;
            len = 1;
          }
          j++;
        }
        if (cnt >= mid) {
          c = true;
          break;
        }
      }
    if (c)
      ok = mid;
    else
      ng = mid;
  }
  cout << ok << endl;
}
