#include <bits/stdc++.h>
using namespace std;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
const long long infll = 1e18;
const int inf = 1e9;
int lcp[40][40];
string s[maxn];
int32_t main() {
  int n = in(), k = in();
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int where = 0;
      while (where < s[i].size() && where < s[j].size() &&
             s[i][where] == s[j][where])
        where++;
      lcp[i][j] = where;
    }
  }
  int res = 0;
  for (int mask = 0; mask < (1 << n); mask++) {
    if (__builtin_popcount(mask) - k) continue;
    vector<int> Ids;
    for (int i = 0; i < n; i++)
      if (mask >> i & 1) Ids.push_back(i);
    int tot = 0;
    for (int i = 0; i < Ids.size(); i++)
      for (int j = i + 1; j < Ids.size(); j++) tot += lcp[Ids[i]][Ids[j]];
    res = max(res, tot);
  }
  cout << res << endl;
}
