#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> num(26, 0);
    for (ll i = 0; i < N; i++) {
        string P;
        cin >> P;
        num[P[0] - 'A']++;
    }

    ll ans = 0;
    for (ll i = 0; ; i++) {
        sort(num.begin(), num.end(), greater<ll>());

        for (ll j = 0; j < K; j++) {
            if (num[j]-- == 0) {
                cout << ans << endl;
                return 0;
            }
        }
        ans++;
    }
}