#include <bits/stdc++.h>
using namespace std;
char _;
const int maxN = 100 * 1000 + 5;
const int mod = 1000 * 1000 * 1000;
const int base = 701;
const int SQ = 317;
const int maxL = 27;
int dp[22][22];
string s[22];
vector<int> tt;
int n, k;
int ans, sum;
void solve(int t) {
  if ((int)tt.size() == k) {
    ans = max(ans, sum);
    return;
  }
  if (t == n) return;
  for (int i = 0; i < (int)tt.size(); i++) sum += dp[tt[i]][t];
  tt.push_back(t);
  solve(t + 1);
  tt.pop_back();
  for (int i = 0; i < (int)tt.size(); i++) sum -= dp[tt[i]][t];
  solve(t + 1);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  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 pp = 0;
      while (pp < (int)s[i].size() && pp < (int)s[j].size() &&
             s[i][pp] == s[j][pp])
        pp++;
      dp[i][j] = pp;
    }
  solve(0);
  cout << ans << endl;
  return 0;
}
