#include <bits/stdc++.h>
using namespace std;
int n, k;
long long cnt = 0;
map<string, bool> bio;
char third(char c1, char c2) {
  int s = 0, e = 0, t = 0;
  if (c1 == 'S' || c2 == 'S') s++;
  if (c1 == 'E' || c2 == 'E') e++;
  if (c1 == 'T' || c2 == 'T') t++;
  if (s == 0) return 'S';
  if (e == 0) return 'E';
  return 'T';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k;
  string s[1510];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    bio[s[i]] = true;
  }
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (j == i) continue;
      string st = s[0];
      vector<int> vec;
      for (int g = 0; g < k; g++) {
        if (s[i][g] == s[j][g])
          st[g] = s[i][g];
        else
          st[g] = third(s[i][g], s[j][g]);
      }
      if (bio[st]) cnt++;
    }
  }
  cout << cnt / 3;
}
