#include <bits/stdc++.h>
using namespace std;
const long maxn = 25;
long best;
long pr[maxn][maxn];
long ch[maxn];
long n, k;
string a[maxn];
void prepare() {
  for (long first = 1; first <= n; first++) {
    for (long second = first + 1; second <= n; second++) {
      pr[first][second] = 0;
      for (long poz = 0; poz < min(a[first].length(), a[second].length());
           poz++) {
        if (a[first][poz] != a[second][poz]) break;
        pr[first][second]++;
      }
    }
  }
}
void go(long step, long amount) {
  if (step == n + 1) {
    if (amount != k) return;
    long nnew = 0;
    for (long first = 1; first <= amount; first++)
      for (long second = first + 1; second <= amount; second++)
        nnew += pr[ch[first]][ch[second]];
    best = max(best, nnew);
    return;
  }
  ch[amount + 1] = step;
  go(step + 1, amount + 1);
  ch[amount + 1] = 0;
  go(step + 1, amount);
}
int main() {
  scanf("%ld%ld", &n, &k);
  for (long q = 1; q <= n; q++) cin >> a[q];
  prepare();
  best = 0;
  go(1, 0);
  printf("%ld", best);
}
