#include <bits/stdc++.h>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int cnt[26] = {0};
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		string a; cin >> a;
		++cnt[a[0] - 'A'];
	}
	priority_queue<int> pq;
	for (int i = 0; i < 26; ++i) {
		if (cnt[i]) pq.push(cnt[i]);
	}
	int ans = 0;
	while (pq.size() >= k) {
		vector<int> tmp;
		for (int i = 0; i < k; ++i) {
			tmp.push_back(pq.top());
			pq.pop();
		}
		for (int i = 0; i < k; ++i) if (tmp[i] > 1) pq.push(tmp[i] - 1);
		++ans;
	}
	cout << ans << '\n';
}
