#include <bits/stdc++.h>
using namespace std;
int n, m, sz[200], first[200][200], a[200];
string second[200];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    cin >> second[i];
    sz[i] = second[i].size();
  }
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      int t = max(sz[i], sz[j]);
      first[i][j] = t;
      for (int k = 0; k < t; ++k)
        if (second[i][k] != second[j][k]) {
          first[i][j] = k;
          break;
        }
    }
  }
  long long ans = 0;
  for (int i = 0; i < (1 << n); ++i) {
    int v = 0;
    for (int j = 0; j < n; ++j) {
      if (i & (1 << j)) a[++v] = j + 1;
    }
    if (v != m) continue;
    long long cnt = 0;
    for (int j = 1; j < m; ++j) {
      for (int k = j + 1; k <= m; ++k) {
        cnt += first[a[j]][a[k]];
      }
    }
    ans = max(ans, cnt);
  }
  printf("%I64d", ans);
  return 0;
}
