#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> hist(26);
	for(int i = 0; i < n; ++i){
		string pi;
		cin >> pi;
		++hist[pi[0] - 'A'];
	}
	priority_queue<int> pq;
	for(const auto x : hist){
		if(x > 0){ pq.push(x); }
	}
	int answer = 0;
	while(pq.size() >= k){
		vector<int> v(k);
		for(int i = 0; i < k; ++i){
			v[i] = pq.top();
			pq.pop();
		}
		for(int i = 0; i < k; ++i){
			if(v[i] > 1){ pq.push(v[i] - 1); }
		}
		++answer;
	}
	cout << answer << endl;
	return 0;
}

