#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  map<string, int> mp;
  string s[n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    mp.insert({s[i], i});
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string to_be = "";
      for (int l = 0; l < k; l++) {
        if (s[i][l] == s[j][l]) {
          to_be += s[i][l];
        } else {
          if (s[i][l] == 'S' && s[j][l] == 'E') {
            to_be += "T";
          } else if (s[i][l] == 'E' && s[j][l] == 'S') {
            to_be += "T";
          } else if (s[i][l] == 'S' && s[j][l] == 'T') {
            to_be += "E";
          } else if (s[i][l] == 'T' && s[j][l] == 'S') {
            to_be += "E";
          } else if (s[i][l] == 'T' && s[j][l] == 'E') {
            to_be += "S";
          } else if (s[i][l] == 'E' && s[j][l] == 'T') {
            to_be += "S";
          }
        }
      }
      cnt += mp.count(to_be);
    }
  }
  cout << cnt / 3 << endl;
  return 0;
}
