#include <bits/stdc++.h>
using namespace std;
int main() {
  string aux;
  int n, k;
  cin >> n >> k;
  vector<string> lista;
  set<string> s;
  for (int i = 0; i < n; i++) {
    cin >> aux;
    lista.push_back(aux);
    s.insert(aux);
  }
  long long int coun = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = i + 1; j < n; ++j) {
      aux = "";
      for (int l = 0; l < k; ++l) {
        if (lista[i][l] == lista[j][l])
          aux += lista[i][l];
        else
          aux += (char)('S' + 'E' + 'T' - lista[i][l] - lista[j][l]);
      }
      if (s.count(aux) != 0) ++coun;
    }
  }
  cout << coun / 3;
}
