#include <cstdio>
#include <algorithm>

using namespace std;

int cont[26];
char s[11];

int main(){
    int N,K;

    scanf("%d %d",&N,&K);

    for(int i = 0;i < N;++i){
        scanf("%s",s);
        ++cont[ s[0] - 'A' ];
    }

    int ans = 0;

    for(int j = N;j >= 1;--j){
        int maxCont = 0,have = 0;
        for(int i = 0;i < 26;++i){
            int aux = min(j,cont[i]);
            maxCont = max(maxCont,aux);
            have += aux;
        }

        while((maxCont + 1) * K <= have){
            ++maxCont;
        }

        if(maxCont * K > have){
            maxCont = 0;
        }

        ans = max(ans,maxCont);
    }

    printf("%d\n",ans);

    return 0;
}
