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