#include <bits/stdc++.h>
using namespace std;
string construct(string &s, string &t) {
  long long i;
  string res = "";
  string c = "SET";
  for (i = 0; i < s.length(); i++) {
    if (s[i] == t[i])
      res += s[i];
    else {
      for (auto j : c) {
        if (s[i] != j && t[i] != j) res += j;
      }
    }
  }
  return res;
}
int32_t main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i, j;
  long long n, k;
  cin >> n >> k;
  unordered_map<string, long long> ump;
  ump.reserve(n + 1);
  vector<string> lav;
  for (i = 0; i < n; i++) {
    string s;
    cin >> s;
    lav.push_back(s);
    ump[s]++;
  }
  long long ans = 0;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      if (lav[i] == lav[j]) {
        ans += ump[lav[i]] - 2;
      } else {
        ans += ump[construct(lav[i], lav[j])];
      }
    }
  }
  cout << ans / 3 << "\n";
  return 0;
}
