#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  int count = 0;
  cin >> n >> k;
  vector<string> cards;
  map<string, int> memo;
  for (int i = 0; i < n; i++) {
    string card;
    cin >> card;
    cards.push_back(card);
    memo[card] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string card1 = cards[i];
      string card2 = cards[j];
      string card3(k, '*');
      for (int m = 0; m < k; m++) {
        char a = card1[m];
        char b = card2[m];
        char c;
        if ((a == 'S' && b == 'T') || (a == 'T' && b == 'S')) {
          c = 'E';
        } else if ((a == 'S' && b == 'E') || (a == 'E' && b == 'S')) {
          c = 'T';
        } else if ((a == 'T' && b == 'E') || (a == 'E' && b == 'T')) {
          c = 'S';
        } else {
          c = a;
        }
        card3[m] = c;
      }
      if (memo.find(card3) != memo.end() && memo[card3] > j) {
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}
