#include <bits/stdc++.h>
using namespace std;
int n, f[21][21], m;
string s[22];
vector<int> v;
int maxi = 0;
void gen(int ind) {
  if (ind == n) {
    if (v.size() == m) {
      int s = 0;
      for (int i = 0; i < m; i++)
        for (int j = i + 1; j < m; j++) s += f[v[i]][v[j]];
      maxi = max(maxi, s);
    }
  } else {
    v.push_back(ind);
    gen(ind + 1);
    v.pop_back();
    gen(ind + 1);
  }
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) {
    f[i][i] = s[i].size();
    for (int j = 0; j < n; j++)
      if (i != j) {
        int ans = 0;
        while (ans < s[i].size() && ans < s[j].size() && s[i][ans] == s[j][ans])
          ans++;
        f[i][j] = ans;
      }
  }
  gen(0);
  cout << maxi;
  return 0;
}
