#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, K, i, j, k, ct = 0;
  cin >> n >> K;
  set<string> S;
  string s;
  vector<string> V;
  for (i = 0; i < n; i++) {
    cin >> s;
    V.push_back(s);
    S.insert(s);
  }
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      string s1 = "";
      for (k = 0; k < K; k++) {
        if (V[i][k] == V[j][k]) {
          s1.push_back(V[i][k]);
        } else {
          if (V[i][k] == 'S' && V[j][k] == 'T')
            s1.push_back('E');
          else if (V[i][k] == 'S' && V[j][k] == 'E')
            s1.push_back('T');
          else if (V[i][k] == 'T' && V[j][k] == 'S')
            s1.push_back('E');
          else if (V[i][k] == 'E' && V[j][k] == 'S')
            s1.push_back('T');
          else
            s1.push_back('S');
        }
      }
      if (S.find(s1) != S.end()) ct++;
    }
  }
  cout << ct / 3 << endl;
}
