#include <bits/stdc++.h>
using namespace std;
int lcp[25][25];
int b[25];
string s[25];
int ans = 0;
void BT(int now, int n, int k) {
  if (now == n) {
    int have = 0;
    for (int i = 0; i < n; i++)
      for (int j = i + 1; j < n; j++)
        if (b[i] && b[j]) have += lcp[i][j];
    ans = max(ans, have);
    return;
  }
  b[now] = 0;
  if (n - now > k) BT(now + 1, n, k);
  if (k) {
    b[now] = 1;
    BT(now + 1, n, k - 1);
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    for (int j = 0; j < i; j++) {
      int k;
      for (k = 0; k < s[i].length() && k < s[j].length() && s[i][k] == s[j][k];
           k++)
        ;
      lcp[i][j] = lcp[j][i] = k;
    }
  }
  BT(0, n, k);
  cout << ans << endl;
  return 0;
}
