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

typedef long long ll;

ll n, k, c[30];
set<string> wow;

bool cmp(int a, int b) {
	return a > b;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	memset(c, 0, sizeof(c));

	cin>>n>>k;

  	string a;
	for(ll i=0;i<n;i++) {
		cin>>a;
		if(wow.count(a) == 0) {
			wow.insert(a);
			c[a[0] - 'A']++;
		}
	}

	ll ans = 0;

	while(1) {
		sort(c, c+26, cmp);
		ll used = 0;
		for(ll i=0;i<26;i++) {
			if(c[i] > 0) {
				c[i]--;
				used++;
				if(used == k) break;
			}
		}
		if(used < k) break;
		else ans++;
	}

	cout<<ans<<endl;
}
