#include <bits/stdc++.h>
using namespace std;
vector<string> str(1500);
map<string, int> mp;
map<string, int>::iterator it;
string word;
void call(string ff, string ss, long long sz) {
  for (long long i = 0; i < sz; i++) {
    if (ff[i] == ss[i])
      word += ff[i];
    else
      word += 'S' + 'E' + 'T' - ff[i] - ss[i];
  }
}
int main() {
  long long n, i, j, k, cnt;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> str[i];
    mp.insert({str[i], 0});
  }
  for (i = 0, cnt = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (i != j) {
        call(str[i], str[j], k);
        it = mp.find(word);
        if (it != mp.end()) cnt++;
        word.clear();
      }
    }
  }
  cout << cnt / 3 << endl;
  return 0;
}
