#include <bits/stdc++.h>
using namespace std;
void fun() {
  int n, k;
  cin >> n >> k;
  map<string, int> m;
  string s;
  string a[n];
  for (int i = 0; i < n; i++) {
    cin >> s;
    a[i] = s;
    m[s]++;
  }
  int c = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) {
      s = "";
      for (int p = 0; p < k; p++) {
        if (a[i][p] == a[j][p])
          s += a[i][p];
        else
          s += (char)('S' + 'E' + 'T' - a[i][p] - a[j][p]);
      }
      c += m[s];
    }
  cout << c / 3 << endl;
}
int main() {
  { fun(); }
  return 0;
}
