#include <bits/stdc++.h>
using namespace std;
int n, m;
int i, j, k, l;
const int N = 111 + 66;
const int T = (1 << 15) + 66;
string s[N];
int p[N][N];
long long ans;
int a[N];
bool u[N];
void g(int i, int k, long long res) {
  if (k == m) {
    ans = ((ans) > (res) ? (ans) : (res));
    return;
  }
  if (i == n) return;
  g(i + 1, k, res);
  int t = 0;
  for (j = 0; j < k; ++j) t += p[i][a[j]];
  a[k] = i;
  g(i + 1, k + 1, res + t);
}
int main() {
  cin >> n >> m;
  for (int _ = 0; _ < n; ++_) cin >> (s)[_];
  ;
  for (i = 0; i < n; ++i)
    for (j = 0; j < n; ++j) {
      for (k = 0; k < s[i].size() && k < s[j].size() && s[i][k] == s[j][k]; ++k)
        ;
      p[i][j] = k;
    }
  g(0, 0, 0);
  cout << ans << endl;
  return 0;
}
