#include <bits/stdc++.h>
using namespace std;
string str[21];
int lcp[21][21];
int find_lcp(string &x, string &y) {
  int i;
  int n = min(x.size(), y.size());
  for (i = 0; i < n; ++i) {
    if (x[i] != y[i]) break;
  }
  return i;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> str[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      lcp[i][j] = find_lcp(str[i], str[j]);
    }
  }
  int lim = 1 << n;
  int ans = 0;
  for (int mask = 0; mask < lim; ++mask) {
    if (__builtin_popcount(mask) != k) continue;
    vector<int> idx;
    for (int i = 0; i < n; ++i) {
      if (mask & 1 << i) idx.push_back(i);
    }
    int res = 0;
    for (int i = 0; i < k; ++i) {
      for (int j = i + 1; j < k; ++j) {
        res += lcp[idx[i]][idx[j]];
      }
    }
    ans = max(ans, res);
  }
  cout << ans << '\n';
  return 0;
}
