#include <bits/stdc++.h>
using namespace std;
int n, m, c[26]; string s;
int main() {
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		cin >> s;
		c[s[0] - 65]++;
	}
	int ret = 0;
	while(true) {
		sort(c, c + 26, greater<int>());
		int z = *min_element(c, c + m);
		if(z == 0) break;
		for(int i = 0; i < m; i++) c[i]--;
		ret++;
	}
	cout << ret << endl;
	return 0;
}