#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int N,K,c[26];
int main(){
	cin>>N>>K;
	rep(i,N){
		string s;
		cin>>s;
		c[s[0]-'A']++;
	}
	int ans=0;
	while(true){
		sort(c,c+26,greater<int>());
		rep(i,K){
			if(c[i]==0){
				cout<<ans<<endl;
				return 0;
			}
			c[i]--;
		}
		ans++;
	}
}
