#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<string> v(n);
  map<string, long long> ktt;
  for (long long i = 0; i < n; i++) {
    cin >> v[i];
    ktt[v[i]] = i + 1;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      string find;
      for (long long x = 0; x < k; x++) {
        if (v[i][x] == v[j][x]) {
          find += v[i][x];
        } else {
          if (v[i][x] == 'S' && v[j][x] == 'E' ||
              v[i][x] == 'E' && v[j][x] == 'S') {
            find += "T";
          }
          if (v[i][x] == 'T' && v[j][x] == 'E' ||
              v[i][x] == 'E' && v[j][x] == 'T') {
            find += "S";
          }
          if (v[i][x] == 'S' && v[j][x] == 'T' ||
              v[i][x] == 'T' && v[j][x] == 'S') {
            find += "E";
          }
        }
      }
      if (ktt[find] != 0 && ktt[find] > ktt[v[j]]) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
