#include <bits/stdc++.h>
using namespace std;
int n, k;
string a[2005];
int common[2005][2005];
int main() {
  std::ios::sync_with_stdio(false);
  cin >> n >> k;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++)
      for (int k = 0; k < a[i].size() && k < a[j].size(); k++)
        if (a[i][k] == a[j][k])
          common[i][j] = k + 1;
        else
          break;
  int ans = 0;
  for (int i = 0; i < (1 << n); i++)
    if (__builtin_popcount(i) == k) {
      int cur = 0;
      for (int j = 0; j < n; j++)
        if (i & (1 << j))
          for (int k = j + 1; k < n; k++)
            if (i & (1 << k)) cur += common[j][k];
      if (cur > ans) ans = cur;
    }
  cout << ans << endl;
  return 0;
}
