#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  string s;
  set<string> card_bank;
  std::vector<string> cards;
  std::map<int, char> diff_feat;
  diff_feat['S' + 'T'] = 'E';
  diff_feat['S' + 'E'] = 'T';
  diff_feat['E' + 'T'] = 'S';
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> s;
    cards.push_back(s);
    card_bank.insert(s);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string aux_card = "";
      for (int feat = 0; feat < k; feat++) {
        if (cards[i][feat] == cards[j][feat])
          aux_card += cards[i][feat];
        else
          aux_card += diff_feat[cards[i][feat] + cards[j][feat]];
      }
      if (card_bank.find(aux_card) != card_bank.end()) ans++;
    }
  }
  printf("%d\n", ans / 3);
}
