#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n = 0, k = 0;
  while (cin >> n >> k) {
    string s;
    cin >> s;
    set<char> s1;
    for (int i = 0; i < n; i++) s1.insert(s[i]);
    map<string, int> m;
    for (set<char>::iterator it = s1.begin(); it != s1.end(); ++it) {
      int same_num = 0;
      for (int i = 0; i < n; i++) {
        if (s[i] != *it) {
          same_num = 0;
          continue;
        }
        if (same_num == 0 || s[i] == s[i - 1]) same_num++;
        if (same_num == k) {
          string neww = s.substr(i - k + 1, k);
          if (m.find(neww) == m.end())
            m.insert(make_pair(neww, 1));
          else
            m[neww]++;
          same_num = 0;
        }
      }
    }
    int maxx = -0x3f3f3f3f;
    for (map<string, int>::iterator it = m.begin(); it != m.end(); ++it)
      maxx = max(maxx, it->second);
    cout << (maxx == -0x3f3f3f3f ? 0 : maxx) << endl;
  }
  return 0;
}
