// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MAX = 1e6;
signed main(){
  init_io();
  ll n,k;
  cin >> n >> k;
  vector<string> p(n);
  vector<ll> cnt(26,0),prob(MAX,0);
  for(int i=0;i<n;i++){
    cin >> p[i];
    cnt[p[i][0]-'A']++;
  }
  ll ans = 0;
  while(true){
    bool can =true;
    sort(cnt.begin(),cnt.end(),greater<ll>());
    for(int i=0;i<k;i++){
      cnt[i]--;
      if(cnt[i]<0){
        can = false;
        break;
      }
    }
    if(!can) break;
    ans++;
  }
  cout << ans << endl;
}
