#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

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

int main() {
    int n, k, ans = 0, i;
    vector <int> v;
    
    scanf("%d %d", &n, &k);
    
    for (i = 0; i < n; i++) {
        scanf("%s", s);
        
        a[s[0] - 'A']++;
    }
    
    for (i = 0; i < 26; i++) {
        if (a[i] > 0) v.push_back(a[i]);
    }
    
    while (v.size() >= k) {
        vector <int> w;
        
        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        
        for (i = 0; i < k; i++) v[i]--;
        
        ans++;
        
        for (i = 0; i < v.size(); i++) {
            if (v[i] > 0) w.push_back(v[i]);
        }
        
        v = w;
    }
    
    printf("%d\n", ans);
    
    return 0;
}
