#include <bits/stdc++.h>
using namespace std;
int find(string s, vector<string>& v, int l, int h) {
  while (l <= h) {
    int m = (l + h) / 2;
    if (v[m] == s) return 1;
    if (v[m] < s)
      l = m + 1;
    else
      h = m - 1;
  }
  return 0;
}
int main() {
  int n, k;
  cin >> n >> k;
  vector<string> v(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  unordered_set<string> z;
  for (int i = 0; i < n; ++i) z.insert(v[i]);
  long long count = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (i == j) continue;
      string s1 = v[i];
      string s2 = v[j];
      string s(k, 'x');
      for (int x = 0; x < k; ++x) {
        if (s1[x] == s2[x])
          s[x] = s1[x];
        else {
          s[x] = 'S' + 'E' + 'T' - s1[x] - s2[x];
        }
      }
      if (z.find(s) != z.end()) count++;
    }
  }
  cout << count / 6;
  return 0;
}
