#include <bits/stdc++.h>
const int MAXN = 20, MAXLEN = 500;
char prot[MAXN][MAXLEN + 1];
int lcp_ar[MAXN][MAXN];
inline int bit_cnt(int n) {
  int ret = 0;
  for (; n; n >>= 1) ret += (n & 1);
  return ret;
}
int lcp(char *s1, char *s2) {
  int ret = 0;
  for (; s1[ret] != '\0' && s1[ret] == s2[ret]; ++ret)
    ;
  return ret;
}
int main() {
  int n, k, i, j, mask, lim, deg[2];
  int ans = 0, tmp;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; ++i) scanf("%s", prot[i]);
  for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j) lcp_ar[i][j] = lcp(prot[i], prot[j]);
  for (mask = 1, lim = (1 << n); mask < lim; ++mask)
    if (bit_cnt(mask) == k) {
      tmp = 0;
      for (i = 0, deg[0] = 1; deg[0] <= mask; ++i, deg[0] <<= 1)
        if (mask & (deg[0]))
          for (j = i + 1, deg[1] = (deg[0] << 1); deg[1] <= mask;
               ++j, deg[1] <<= 1)
            if (mask & (deg[1])) tmp += lcp_ar[i][j];
      if (ans < tmp) ans = tmp;
    }
  printf("%d\n", ans);
  return 0;
}
