#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
int b[2010 * 510][26], w[2010 * 510], e[2010 * 510], v[2010 * 510],
    h = 1, d[2 * 2010][2010], p[2010], l;
char s[510];
void add() {
  int i, t;
  for (v[0]++, t = 0, i = 0; s[i]; t = b[t][s[i] - 'a'], v[t]++, i++)
    if (!b[t][s[i] - 'a']) b[t][s[i] - 'a'] = h++;
}
void dfs(int i) {
  int j, k, t, s, f;
  for (f = !i, j = 0; j < 26; j++)
    if (b[i][j]) {
      f++;
      f += v[b[i][j]] != v[i];
      dfs(b[i][j]);
    }
  if (f == 1) {
    for (j = 0; j < 26 && !b[i][j]; j++)
      ;
    w[i] = w[b[i][j]];
    e[i] = e[b[i][j]] + 1;
  } else {
    w[i] = h++;
    e[i] = 1;
    for (s = 0, j = 0; j < 26; j++)
      if (b[i][j]) {
        t = b[i][j];
        for (k = 0; k <= l && k <= s; k++)
          for (f = 0; k + f <= l && f <= v[t]; f++)
            if (d[w[i]][k] + d[w[t]][f] + f * (f - 1) / 2 * e[t] > p[k + f])
              p[k + f] = d[w[i]][k] + d[w[t]][f] + f * (f - 1) / 2 * e[t];
        s += v[t];
        for (k = 0; k <= l && k <= s; d[w[i]][k] = p[k], p[k] = 0, k++)
          ;
      }
    for (s++; s <= l && s <= v[i]; d[w[i]][s] = d[w[i]][s - 1], s++)
      ;
  }
}
int main() {
  int i, n;
  for (scanf("%d%d", &n, &l), i = 0; i < n; scanf("%s", s), add(), i++)
    ;
  h = 0;
  dfs(0);
  printf("%d\n", d[w[0]][l]);
  return 0;
}
