#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
int d[22][22];
int bits(int x) {
  int r = 0;
  while (x != 0) {
    ++r;
    x &= (x - 1);
  }
  return r;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<string> s(n);
  for (int(i) = 0; (i) < (n); (i)++) cin >> s[i];
  for (int(i) = 0; (i) < (n); (i)++)
    for (int(j) = 0; (j) < (n); (j)++) {
      d[i][j] = min((int)(s[i]).size(), (int)(s[j]).size());
      for (int(k) = 0; (k) < (min((int)(s[i]).size(), (int)(s[j]).size()));
           (k)++) {
        if (s[i][k] != s[j][k]) {
          d[i][j] = k;
          break;
        }
      }
    }
  int res = 0;
  for (int(mask) = 0; (mask) < (1 << n); (mask)++) {
    if (bits(mask) == k) {
      int cur = 0;
      for (int(i) = 0; (i) < (n); (i)++) {
        if (mask & (1 << i)) {
          for (int(j) = 0; (j) < (i); (j)++) {
            if (mask & (1 << j)) {
              cur += d[i][j];
            }
          }
        }
      }
      res = max(res, cur);
    }
  }
  cout << res;
  return 0;
}
