#include <bits/stdc++.h>
using namespace std;
string e[1505];
int n, K;
int main() {
  ios::sync_with_stdio(false);
  map<string, int> M;
  string T;
  int S = 'S' + 'E' + 'T';
  long long ans = 0;
  cin >> n >> K;
  for (int i = 1; i <= n; ++i) cin >> e[i], M[e[i]]++;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      if (i == j) continue;
      T = "";
      for (int o = 0; o < K; ++o) {
        if (e[i][o] == e[j][o])
          T += e[i][o];
        else {
          T += (char)(S - e[i][o] - e[j][o]);
        }
      }
      if (M.find(T) != M.end()) ans += M[T];
    }
  }
  cout << ans / 3 << endl;
  return 0;
}
