Problem:
Score : 100 points

Problem Statement

Kyoto University Programming Contest is a programming contest voluntarily held by some Kyoto University students.
This contest is abbreviated as Kyoto University Programming Contest and called KUPC.

source: Kyoto University Programming Contest Information

The problem-preparing committee met to hold this year's KUPC and N problems were proposed there.
The problems are numbered from 1 to N and the name of i-th problem is P_i.
However, since they proposed too many problems, they decided to divide them into some sets for several contests.

They decided to divide this year's KUPC into several KUPCs by dividing problems under the following conditions.

One KUPC provides K problems.

Each problem appears at most once among all the KUPCs.

All the first letters of the problem names in one KUPC must be different.

You, one of the committee members, want to hold as many KUPCs as possible.
Write a program to find the maximum number of KUPCs that can be held this year.

Constraints

1 \leq N \leq 10^4

1 \leq K \leq 26

1 \leq |P_i| \leq 10

All characters in P_i are capital letters.

Note that, for each i and j (1 \leq i < j \leq N),
P_i \neq P_j are not necessarily satisfied.

Input

The input is given from Standard Input in the following format:

N K
P_1
:
P_N

Output

Print the maximum number of KUPCs that can be held on one line.

Sample Input 1

9 3
APPLE
ANT
ATCODER
BLOCK
BULL
BOSS
CAT
DOG
EGG

For example, three KUPCs can be held by dividing the problems as follows.

First: APPLE, BLOCK, CAT

Second: ANT, BULL, DOG

Third: ATCODER, BOSS, EGG

Sample Output 1

3

Sample Input 2

3 2
KU
KYOUDAI
KYOTOUNIV

Sample Output 2

0

No KUPC can be held.

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <algorithm>//min/max/sort(rand-access it)/merge
#include <array>
#include <bitset>
#include <climits>//INT_MAX/INT_MIN/ULLONG_MAX
#include <cmath>//fmin/fmax/fabs/sin(h)/cos(h)/tan(h)/exp/log/pow/sqrt/cbrt/ceil/floor/round/trunc
#include <cstdlib>//abs/atof/atoi/atol/atoll/strtod/strtof/..., srand/rand, calloc/malloc, exit, qsort
#include <iomanip>//setfill/setw
#include <iostream>//cin/cout/wcin/wcout/left/right/internal/dec/hex/oct/fixed/scientific
#include <iterator>
#include <list>
#include <queue>
#include <string>//stoi/stol/stoul/stoll/stoull/stof/stod/stold/to_string/getline
#include <tuple>
#include <utility>//pair
#include <valarray>
#include <vector>

#define PRIME_SHORT 10007
#define PRIME 1000000007

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<ull, int> puli;
typedef pair<double, int> pdi;
typedef pair<ll, ll> pllll;
typedef pair<ull, ull> pulul;
typedef pair<double, double> pdd;
typedef tuple<int, int, int> ti3;
typedef tuple<int, int, int, int> ti4;

const bool debug = true;

void rar(int n, string* a);
void rar2(int n, int m, int** a);

int ipow(int base, int exp);
int left(int current, bool swap);
int right(int current, bool swap);
int griddist(int x, int y, int s, int t);
int griddist(pii one, pii two);
double sqeucldist(double x, double y, double s, double t);
double sqeucldist(pii one, pii two);
ull modadd(ull a, ull b, int mod);
ull modmult(ull a, ull b, int mod);

int main(void) {
    ui n;
    cin >> n;
    size_t k;
    cin >> k;

    ui header_count[26];
    for (size_t i = 0; i < 26; ++i)
        header_count[i] = 0U;

    string p;
    for (size_t i = 0; i < n; ++i)
    {
        cin >> p;
        int index = p[0] - 'A';
        if (debug)
            cout << p << " " << index << endl;
        ++(header_count[index]);
    }

    list<ui> remaining;

    for (size_t i = 0; i < 26; ++i)
    {
        if (header_count[i] > 0)
            remaining.push_back(header_count[i]);
    }
    
    if (debug){
        cout << "remaining" << endl;
        for (list<ui>::iterator it = remaining.begin(); it != remaining.end(); ++it)
            cout << *it << "\t";
        cout << endl;
    }

    remaining.sort(greater<ui>());
    
    if (debug) {
        cout << "remaining" << endl;
        for (list<ui>::iterator it = remaining.begin(); it != remaining.end(); ++it)
            cout << *it << "\t";
        cout << endl;
    }

    ull count = 0UL;

    size_t s = remaining.size();
    while(s >= k) {
        if (debug) {
            for (list<ui>::iterator it = remaining.begin(); it != remaining.end(); ++it)
                cout << *it << " ";
            cout << endl;
        }

        int i = 0;
        for (list<ui>::iterator it = remaining.begin(); i < k; ++i)
        {
            --(*it);
            if (*it == 0) {
                it = remaining.erase(it);
                continue;
            }
            ++it;
        }
        ++count;
        remaining.sort(greater<ui>());
        s = remaining.size();
    }

    cout << count << endl;
    return 0;
}

void rar(int n, string* a)
{
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    return;
}

void rar2(int n, int m, int** a)
{
    for (int i = 0; i < n; ++i)
    {
        a[i] = new int[m];
        for (int j = 0; j < m; ++j)
        {
            cin >> a[i][j];
        }
    }
    return;
}



















int ipow(int base, int exp) {
    int result = 1;
    while (exp)
    {
        if (exp & 1)
            result *= base;
        exp >>= 1;
        base *= base;
    }

    return result;
}
int left(int current, bool swap = false) {
    if(swap){
        return right(current, false);
    } else {
        return 2*current + 1;
    }
}
int right(int current, bool swap = false) {
    if(swap){
        return left(current, false);
    } else {
        return 2*(current+1);
    }
}
int griddist(int x, int y, int s, int t) {
    return abs(x-s) + abs(y-t);
}
int griddist(pii one, pii two) {
    return abs(one.first - two.first) + abs(one.second - two.second);
}
double sqeucldist(double x, double y, double s, double t) {
    double a = x-s;
    double b = y-t;
    return a*a+b*b;
}
double sqeucldist(pii one, pii two) {
    double a = one.first - two.first;
    double b = one.second - two.second;
    return a*a+b*b;
}

ull modadd(ull a, ull b, int mod) {
    return (a%mod + b%mod)%mod;
}
ull modmult(ull a, ull b, int mod) {
    return ((a%mod)*(b%mod))%mod;
}