#include <bits/stdc++.h>
using namespace std;
const int mx = 200050;
int arr[30][mx];
int main() {
  string str;
  int i, j, l, k, n, m, p;
  scanf("%d %d", &n, &k);
  cin >> str;
  int idx, cnt;
  for (i = 0; i < n; i++) {
    idx = (int)str[i] - 'a';
    cnt = 1;
    while (i < n && str[i] == str[i + 1]) {
      i++;
      cnt++;
    }
    for (j = 1; j <= cnt; j++) {
      p = cnt / j;
      arr[idx][j] += p;
    }
  }
  int ans = 0;
  for (j = 0; j < 26; j++) {
    if (arr[j][k]) {
      ans = max(ans, arr[j][k]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
