#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, kk;
  cin >> n >> kk;
  vector<string> v(n);
  unordered_map<string, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  int ans = 0;
  string req;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      req = "";
      for (int k = 0; k < kk; k++) {
        if (v[i][k] == v[j][k])
          req.push_back(v[i][k]);
        else {
          if (v[i][k] == 'T' && v[j][k] == 'T') req.push_back('T');
          if (v[i][k] == 'S' && v[j][k] == 'S') req.push_back('S');
          if (v[i][k] == 'E' && v[j][k] == 'E') req.push_back('E');
          if (v[i][k] == 'T' && v[j][k] == 'S') req.push_back('E');
          if (v[i][k] == 'S' && v[j][k] == 'T') req.push_back('E');
          if (v[i][k] == 'T' && v[j][k] == 'E') req.push_back('S');
          if (v[i][k] == 'E' && v[j][k] == 'T') req.push_back('S');
          if (v[i][k] == 'S' && v[j][k] == 'E') req.push_back('T');
          if (v[i][k] == 'E' && v[j][k] == 'S') req.push_back('T');
        }
      }
      if (mp[req]) ans++;
    }
  }
  cout << ans / 3 << endl;
}
signed main() {
  solve();
  return 0;
}
