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

int main() {

    int N,K;
    cin >> N >> K;

    string s[N];
    map<char,int> x;
    for(int i=0; i<N; i++) {
	string s; cin >> s;
	if( x.find(s[0]) == x.end() )
	    x[s[0]] = 1;
	else
	    x[s[0]] ++;
    }
    vector<int> num;
    for(auto e : x)  num.push_back(e.second);

    int ans = 0;
    while(1) {

	sort(num.begin(),num.end());
	reverse(num.begin(),num.end());

	if(num.size() < K or num[K-1] == 0) break;
	ans ++;
	for(int i=0; i<K; i++) num[i]--;
	for(int i=num.size()-1; i>=0; i--) {
	    if(num[i] == 0) num.pop_back();
	    else            break;
	}
    }
    cout << ans << endl;
    
}
