#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<string> cards(n);
  map<string, int> lookup;
  for (string &card : cards) {
    cin >> card;
    if (lookup.find(card) == lookup.end()) {
      lookup[card] = 1;
    } else {
      lookup[card] += 1;
    }
  }
  string possible = "SET";
  int ans = 0;
  for (int i = 0; i + 1 < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      string third;
      third.resize(k);
      for (int l = 0; l < k; ++l) {
        if (cards[i][l] == cards[j][l]) {
          third[l] = cards[i][l];
        } else {
          for (char c : possible) {
            if (cards[i][l] != c && cards[j][l] != c) {
              third[l] = c;
            }
          }
        }
      }
      if (lookup.find(third) != lookup.end()) {
        ans += lookup[third];
      }
    }
  }
  cout << ans / 3 << '\n';
}
