#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string st = "";
      for (int m = 0; m < k; m++) {
        if (s[i][m] == s[j][m]) {
          st = st + s[i][m];
        } else if (s[i][m] == 'S' && s[j][m] == 'E') {
          st += 'T';
        } else if (s[i][m] == 'S' && s[j][m] == 'T') {
          st += 'E';
        } else if (s[i][m] == 'E' && s[j][m] == 'S') {
          st += 'T';
        } else if (s[i][m] == 'E' && s[j][m] == 'T') {
          st += 'S';
        } else if (s[i][m] == 'T' && s[j][m] == 'S') {
          st += 'E';
        } else if (s[i][m] == 'T' && s[j][m] == 'E') {
          st += 'S';
        }
      }
      if (binary_search(s.begin(), s.end(), st)) ans++;
    }
  }
  cout << ans / 3;
  return 0;
}
