#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a * (b / gcd(a, b)); }
map<string, long long> mapa;
int32_t main(int32_t argc, char const *argv[]) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  long long i = 1;
  string t = "";
  char a;
  a = s[0];
  t += a;
  if (k == 1) {
    for (long long i = 0; i < n; i++) {
      t = s[i];
      mapa[t]++;
    }
    long long m = 0;
    for (auto x : mapa) m = max(m, x.second);
    cout << m;
    return 0;
  }
  while (i < n) {
    if (s[i] == a) {
      t += s[i];
    } else {
      t = "";
      t += s[i];
      a = s[i];
    }
    if (((long long)(t).size()) == k) {
      mapa[t]++;
      t = "";
      i++;
      t += s[i];
      a = s[i];
    }
    i++;
  }
  long long m = 0;
  for (auto x : mapa) m = max(m, x.second);
  cout << m;
  return 0;
}
