#include <bits/stdc++.h>

using namespace std;

struct info{

};
int take[27];
int main() {
  int n , k ; cin>>n>>k;
  for(int i = 0 ; i < n; ++i){
    string s ; cin>>s;
    take[s[0] - 'A']++;
  }
  int L = 0 , R = n;
  while(L <= R){
    int mid = (L + R) >> 1;
    int now = 0;
    for(int i = 0;  i < 26; ++i){
      now += min(mid , take[i]);
    }
    if(now >= k * mid){
      L = mid + 1;

    }else R = mid - 1;
  }
  cout<<((L + R)>>1)<<endl;

}