#include <bits/stdc++.h>
using namespace std;
void swap(long long* a, long long* b) {
  long long temp = *a;
  *a = *b;
  *b = temp;
}
char nxtchr(long long c) {
  if (c == 1) return '1';
  if (c == 2) return '2';
  if (c == 3) return '3';
  if (c == 4) return '4';
  if (c == 5) return '5';
  if (c == 6) return '6';
  if (c == 7) return '7';
  if (c == 8) return '8';
  if (c == 9) return '9';
  if (c == 0) return '0';
  return -1;
}
int32_t main() {
  long long n, k, cnt = 0, ans = 0;
  cin >> n >> k;
  string s[n], tmp;
  map<string, vector<long long>> pos;
  for (long long i = 0; i < n; i++) {
    cin >> s[i];
    pos[s[i]].push_back(i);
  }
  for (long long i = 0; i < n; i++) {
    string s1 = s[i];
    for (long long l = i + 1; l < n; l++) {
      cnt = 0;
      string s2 = s[l];
      tmp = "";
      for (long long j = 0; j < k; j++) {
        if (s1[j] == 'S' && s2[j] == 'S') tmp += "S";
        if (s1[j] == 'S' && s2[j] == 'E') tmp += "T";
        if (s1[j] == 'S' && s2[j] == 'T') tmp += "E";
        if (s1[j] == 'E' && s2[j] == 'E') tmp += "E";
        if (s1[j] == 'E' && s2[j] == 'S') tmp += "T";
        if (s1[j] == 'E' && s2[j] == 'T') tmp += "S";
        if (s1[j] == 'T' && s2[j] == 'T') tmp += "T";
        if (s1[j] == 'T' && s2[j] == 'S') tmp += "E";
        if (s1[j] == 'T' && s2[j] == 'E') tmp += "S";
      }
      for (long long j = 0; j < pos[tmp].size(); j++) {
        if (pos[tmp][j] > l) cnt++;
      }
      ans += cnt;
    }
  }
  cout << ans << "\n";
}
