#include <bits/stdc++.h>
char str[30][510];
int len[50];
int dis[30][30];
int main() {
  int n, k, i, j, m, s;
  while (scanf("%d%d", &n, &k) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%s", str[i]);
      len[i] = strlen(str[i]);
    }
    for (i = 0; i < n; i++) {
      for (j = i + 1; j < n; j++) {
        for (s = 0; s < len[i] && s < len[j]; s++)
          if (str[i][s] != str[j][s]) break;
        dis[i][j] = dis[j][i] = s;
      }
    }
    int ans = 0;
    for (i = 0; i < (1 << n); i++) {
      for (j = 0, m = 0; j < n; m += (i >> j) & 1, j++)
        ;
      if (m != k) continue;
      for (m = 0, j = 0; j < n; j++)
        if ((i >> j) & 1)
          for (int x = j + 1; x < n; x++)
            if ((i >> x) & 1) m += dis[j][x];
      if (m > ans) ans = m;
    }
    printf("%d\n", ans);
  }
  return 0;
}
