#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
 
using namespace std;

#define mod 1000000007

int main()
{
    int n, k;
    int pnum[26] = {};
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        string p;
        cin >> p;
        pnum[p[0] - 'A']++;
    }
    int ans = 0;
    while(1){
        int probnum = 0;
        sort(pnum, pnum + 26);
        for(int i = 25; i >= 0; i--){
            if(pnum[i] > 0){
                probnum++;
                pnum[i]--;
            }
            if(probnum == k) break;
        }
        // cout << probnum << endl;
        if(probnum == k) ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}