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

#define pii pair<int, int>
#define vii vector<pii>
#define ll long long
#define mp(x, y) make_pair(x, y)
#define pb(x) push_back(x)

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	char in_buffer[15] = {};
	int count[30] = {};
	for(int i = 0; i < n; i++) {
		scanf("%s", in_buffer);
		count[in_buffer[0]-'A']++;
	}
	
	priority_queue<int> pq;
	for(int i = 0; i < 26; i++) {
		if(count[i] != 0) {
			pq.push(count[i]);
		}
	}
	
	int used = 0;
	while(pq.size() >= k) {
		used += k;
		vector<int> temp;
		for(int i = 0; i < k; i++) {
			if(pq.top() > 1)
				temp.pb(pq.top()-1);
			pq.pop();
		}
		
		for(int i = 0; i < temp.size(); i++) {
			pq.push(temp[i]);
		}
		
	}
	printf("%d\n", used/k);
}