#include <bits/stdc++.h>
using namespace std;
int n, k;
string s[30];
int lcp[30][30];
int main() {
  cin >> n >> k;
  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 cur = 0;
      while (cur < s[i].length() && cur < s[j].length() &&
             s[i][cur] == s[j][cur])
        ++cur;
      lcp[i][j] = cur;
    }
  }
  vector<int> tn(k);
  int result = 0;
  for (int i = 0; i < (1 << n); ++i) {
    bitset<20> b = i;
    if (b.count() == k) {
      int ind = 0;
      for (int j = 0; j < n; ++j) {
        if (b[j]) {
          tn[ind] = j;
          ++ind;
        }
      }
      int cur = 0;
      for (int j = 0; j < k; ++j) {
        for (int l = j + 1; l < k; ++l) {
          cur += lcp[tn[j]][tn[l]];
        }
      }
      result = max(result, cur);
    }
  }
  cout << result << endl;
  return 0;
}
