#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<string> v(n);
  set<string> s;
  for (int i = 0; i < n; ++i) {
    cin >> v[i];
    s.insert(v[i]);
  }
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      string str(k, ' ');
      for (int u = 0; u < k; ++u) {
        if (v[i][u] == v[j][u]) {
          str[u] = v[i][u];
        } else {
          int ch = 'E' + 'S' + 'T';
          ch -= v[i][u];
          ch -= v[j][u];
          str[u] = static_cast<char>(ch);
        }
      }
      if (s.count(str) > 0) {
        ++res;
      }
    }
  }
  cout << res / 3 << endl;
  return 0;
}
