#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
using namespace std;
int n, k, a[26]; string S;
int main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> S; a[S[0] - 'A']++;
	}
	sort(a, a + 26, greater<int>()); int cnt = 0;
	while (true) {
		bool OK = true;
		for (int i = 0; i < k; i++) {
			a[i]--; if (a[i] < 0)OK = false;
		}
		if (OK == false)break;
		cnt++;
		sort(a, a + 26, greater<int>());
	}
	cout << cnt << endl;
	return 0;
}