#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const ut INF=1LL<<30;
const int SIZE=2001;
int nums[26];
int main(){
	int N,K;
	cin >> N >> K;
	string s;
	REP(i,N){
		cin >> s;
		nums[s[0]-'A']++;
	}
	PQ qu;
	REP(i,'Z'-'A'+1){
		if(nums[i])
			qu.push(nums[i]);
	}
	int ans=0;
	bool playable=true;
	while(true){
		VI tmp;
		REP(i,K){
			if(qu.empty()){
				playable=false;
				break;
			}
			tmp.PB(qu.top()-1);
			qu.pop();
		}
		if(playable){
			ans++;
			REP(i,K) if(tmp[i]) qu.push(tmp[i]);
		}
		else{
			break;
		}
	}
	cout << ans << endl;
}