#include <bits/stdc++.h>
using namespace std;
bool fun(string s1, string s2, string s3) {
  int i;
  for (i = 0; i < s1.size(); i++) {
    if (s1[i] == s2[i] && s2[i] == s3[i] && s1[i] == s3[i]) continue;
    if (s1[i] != s2[i] && s2[i] != s3[i] && s1[i] != s3[i])
      continue;
    else
      return false;
  }
  return true;
}
int main() {
  int n, k, i, j, cnt = 0, l;
  cin >> n >> k;
  vector<string> v(n);
  for (i = 0; i < n; i++) cin >> v[i];
  if (n < 3) {
    cout << 0;
    return 0;
  }
  unordered_map<string, int> m;
  string set = "SET";
  for (i = 0; i < n; i++) m[v[i]] = i;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      string s;
      for (l = 0; l < k; l++) {
        if (v[i][l] == v[j][l])
          s += v[i][l];
        else {
          string st = set;
          st.erase(find(st.begin(), st.end(), v[i][l]));
          st.erase(find(st.begin(), st.end(), v[j][l]));
          s += st[0];
        }
      }
      if (m.find(s) != m.end()) cnt++;
    }
  }
  cout << cnt / 3;
}
