#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
int A[maxn][maxn];
int B[maxn];
string s[maxn];
int pref(string& a, string& b) {
  for (int i = 0; i < min(((int)(a).size()), ((int)(b).size())); ++i) {
    if (a[i] != b[i]) {
      return i;
    }
  }
  return min(((int)(a).size()), ((int)(b).size()));
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      A[i][j] = pref(s[i], s[j]);
    }
  }
  int mm = 1 << n;
  int res = 0;
  for (int mask = 0; mask < mm; ++mask) {
    int m = 0;
    for (int i = 0; i < n; ++i) {
      if (mask & (1 << i)) {
        B[m++] = i;
      }
    }
    if (m != k) {
      continue;
    }
    int _res = 0;
    for (int i = 0; i < m; ++i) {
      for (int j = i + 1; j < m; ++j) {
        _res += A[B[i]][B[j]];
      }
    }
    res = max(res, _res);
  }
  cout << res << '\n';
  return 0;
}
