#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int N, K;
int num[26];

bool ok(int x)
{
	int s = 0;
	rep(i, 26) s += min(num[i], x);
	return s >= K * x;
}

int main() {
	cin >> N >> K;

	rep(i, N) {
		string s;
		cin >> s;
		++num[s[0] - 'A'];
	}

	if (!ok) {
		puts("0");
		return 0;
	}
	int lo = 0, hi = N + 1;
	while (hi - lo > 1) {
		int m = (lo + hi) / 2;
		if (ok(m)) lo = m;
		else hi = m;
	}

	cout << lo << endl;
	return 0;
}