#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;

#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, K;
int cnt[27];
char in[10101][20];

int main()
{
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; ++i) {
		scanf("%s", in[i]);
		cnt[in[i][0] - 'A']++;
	}
	int ret = 0;
	priority_queue<int> q;
	for (int i = 0; i < 26; ++i) if (cnt[i] > 0) {
		q.push(cnt[i]);
	}
	for (;;) {
		vector<int> a;
		bool flg = true;
		for (int i = 0; i < K; ++i) {
			if (q.empty()) {
				flg = false;
				break;
			}
			if (q.top() > 1) a.push_back(q.top() - 1);
			q.pop();
		}
		if (!flg) break;
		++ret;
		for (int v : a) if (v != 0) q.push(v);
	}
	printf("%d\n", ret);

	return 0;
}
