#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  unordered_map<char, int> m;
  char last = s[0];
  int streak = 1;
  int cur_max = 0;
  if (k == 1) {
    cur_max = 1;
    m[last] = 1;
    streak = 0;
  }
  for (int i = 1; i < s.size(); i++) {
    if (s[i] == last) {
      streak++;
    } else {
      streak = 1;
    }
    if (streak == k) {
      streak = 0;
      if (m.find(s[i]) == m.end()) {
        m[s[i]] = 1;
      } else {
        m[s[i]]++;
      }
      cur_max = m[s[i]] > cur_max ? m[s[i]] : cur_max;
    }
    last = s[i];
  }
  cout << cur_max << endl;
}
