#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
template <class T>
inline T sqr(T a) {
  return a * a;
}
int n, k;
string s[20];
int c[20][20];
int com(string &s1, string &s2) {
  int l1 = s1.length(), l2 = s2.length();
  for (int i = 0; i < min(l1, l2); ++i)
    if (s1[i] != s2[i]) return i;
  return min(l1, l2);
}
void calc() {
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      c[i][j] = com(s[i], s[j]);
      c[j][i] = c[i][j];
    }
}
int bitc(int mask) {
  int res = 0;
  for (int i = 0; i < n; ++i)
    if (mask & (1 << i)) ++res;
  return res;
}
int sum(int mask) {
  int res = 0;
  for (int i = 0; i < n; ++i) {
    if (!(mask & (1 << i))) continue;
    for (int j = i + 1; j < n; ++j) {
      if (!(mask & (1 << j))) continue;
      res += c[i][j];
    }
  }
  return res;
}
void solve() {
  int res = 0;
  for (int i = 0; i < (1 << n); ++i) {
    if (bitc(i) != k) continue;
    int s = sum(i);
    res = max(res, s);
  }
  cout << res;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; ++i) cin >> s[i];
  calc();
  solve();
  return 0;
}
