#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long int n, k;
  cin >> n >> k;
  string s[n];
  for (long long int i = 0; i < n; i++) cin >> s[i];
  long long int c = 0;
  unordered_map<string, long long int> m;
  for (long long int i = 0; i < n; i++) m[s[i]]++;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i + 1; j < n; j++) {
      string h = "";
      for (long long int l = 0; l < k; l++) {
        if (s[i][l] == s[j][l])
          h += s[i][l];
        else {
          if (s[i][l] == 'S' && s[j][l] == 'E')
            h += 'T';
          else if (s[i][l] == 'E' && s[j][l] == 'S')
            h += 'T';
          else if (s[i][l] == 'S' && s[j][l] == 'T')
            h += 'E';
          else if (s[i][l] == 'T' && s[j][l] == 'S')
            h += 'E';
          else
            h += 'S';
        }
      }
      if (m.count(h) != 0) c += m[h];
    }
  }
  c = c / 3;
  cout << c << endl;
}
