#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string s[n];
  map<string, int> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    m[s[i]] = 1;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string tmp = "";
      for (int kk = 0; kk < k; kk++) {
        if (s[i][kk] == s[j][kk]) tmp += s[i][kk];
        if ((s[i][kk] == 'S' && s[j][kk] == 'T') ||
            (s[i][kk] == 'T' && s[j][kk] == 'S'))
          tmp += 'E';
        if ((s[i][kk] == 'T' && s[j][kk] == 'E') ||
            (s[i][kk] == 'E' && s[j][kk] == 'T'))
          tmp += 'S';
        if ((s[i][kk] == 'E' && s[j][kk] == 'S') ||
            (s[i][kk] == 'S' && s[j][kk] == 'E'))
          tmp += 'T';
      }
      if (m[tmp]) ans++;
    }
  }
  cout << ans / 3;
  return 0;
}
