#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<string> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  unordered_map<string, int> mp;
  for (int i = 0; i < n; i++) {
    mp[v[i]] = i;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string get = "";
      for (int t = 0; t < k; t++) {
        if (v[i][t] == v[j][t]) {
          get += v[i][t];
        } else {
          if (v[i][t] == 'S') {
            if (v[j][t] == 'E') {
              get += 'T';
            } else {
              get += 'E';
            }
          } else if (v[i][t] == 'E') {
            if (v[j][t] == 'S') {
              get += 'T';
            } else {
              get += 'S';
            }
          } else {
            if (v[j][t] == 'S') {
              get += 'E';
            } else {
              get += 'S';
            }
          }
        }
      }
      if (mp[get] > j) {
        ans++;
      }
    }
  }
  cout << ans << "\n";
  return;
}
signed main() {
  auto start = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  auto stop = std::chrono::high_resolution_clock::now();
  auto duration =
      std::chrono::duration_cast<std::chrono::nanoseconds>(stop - start);
  return 0;
}
