#include <bits/stdc++.h>
using namespace std;
bool checkset(vector<string>& card, int i, int j, int k) {
  int sz = card[i].size();
  for (int pos = 0; pos < sz; ++pos) {
    if (card[i][pos] == card[j][pos] && card[j][pos] == card[k][pos]) continue;
    if (card[i][pos] == card[j][pos] || card[j][pos] == card[k][pos] ||
        card[k][pos] == card[i][pos])
      return false;
  }
  return true;
}
int main() {
  int n, sz;
  cin >> n >> sz;
  vector<string> card(n);
  unordered_map<string, int> m;
  unordered_map<string, char> toFind;
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cin >> card[i];
    m[card[i]] = i;
  }
  toFind["ST"] = 'E';
  toFind["TS"] = 'E';
  toFind["ET"] = 'S';
  toFind["TE"] = 'S';
  toFind["SE"] = 'T';
  toFind["ES"] = 'T';
  for (int i = 0; i < n - 2; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      string matched;
      for (int k = 0; k < sz; ++k) {
        if (card[i][k] == card[j][k]) matched.push_back(card[i][k]);
        if (card[i][k] != card[j][k]) {
          string tmp = "";
          tmp += card[i][k];
          tmp += card[j][k];
          matched.push_back(toFind[tmp]);
        }
      }
      if (m.find(matched) != m.end()) {
        if (m[matched] > j) ++cnt;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}
