#include <cstdio>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

int main() {
  size_t N, K;
  scanf("%llu %llu", &N, &K);

  set<string> s;
  for (size_t i=0; i<N; ++i) {
    char buf[1<<4];
    scanf("%s", buf);
    string P(buf);
    s.insert(P);
  }

  map<char, int> m;
  for (string t: s)
    ++m[t[0]];

  int res=0;
  while (true) {
    set<char> used;
    for (size_t i=0; i<K; ++i) {
      int max_=-1;
      char cur='@';
      for (auto u: m) {
        if (u.second>=max_ && !used.count(u.first)) {
          max_ = u.second;
          cur = u.first;
        }
      }
      if (max_ > 0) {
        used.insert(cur);
        --m[cur];
      } else {
        return !printf("%d\n", res);
      }
    }
    ++res;
  }
}
