#include<stdio.h>
#include<algorithm>
using namespace std;
char in[20];
int c[26];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%s",in);
		c[in[0]-'A']++;
	}
	int left=-1;
	int right=20000;
	while(left+1<right){
		int M=(left+right)/2;
		int tmp=0;
		for(int i=0;i<26;i++)tmp+=min(c[i],M);
		if(M*b>tmp)right=M;
		else left=M;
	}
	printf("%d\n",left);
}