#include <bits/stdc++.h>
using namespace std;
char str[25][510];
int g[25][25];
int main() {
  int n, m, i, j, l1, l2, fuck, temp, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) scanf("%s", str[i]);
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      temp = 0;
      l1 = strlen(str[i]);
      l2 = strlen(str[j]);
      for (k = 0; k < l1 && k < l2; k++)
        if (str[i][k] != str[j][k]) break;
      k = min(k, l1);
      k = min(k, l2);
      g[i][j] = k;
    }
  }
  int tot = (1 << n), ans = 0;
  for (i = 0; i < tot; i++) {
    fuck = 0;
    for (j = 0; j < n; j++) {
      if ((i & (1 << j))) fuck++;
    }
    if (fuck != m) continue;
    temp = 0;
    for (j = 0; j < n; j++) {
      if ((i & (1 << j)) == 0) continue;
      for (k = j + 1; k < n; k++) {
        if ((i & (1 << k)) == 0) continue;
        temp += g[j][k];
      }
    }
    ans = max(ans, temp);
  }
  printf("%d\n", ans);
  return 0;
}
