#include <bits/stdc++.h>
using namespace std;
int a[1510][32], n, k;
char chars[3] = {'S', 'E', 'T'};
unordered_set<string> b;
string s;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> s;
    for (int j = 0; j < k; j++) {
      switch (s[j]) {
        case 'S':
          a[i][j] = 0;
          break;
        case 'E':
          a[i][j] = 1;
          break;
        case 'T':
          a[i][j] = 2;
          break;
      }
    }
    b.insert(s);
  }
  string cur;
  long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      cur = "";
      for (int h = 0; h < k; h++) {
        cur += chars[(3 - (a[i][h] + a[j][h]) % 3) % 3];
      }
      if (b.find(cur) != b.end()) ans++;
    }
  }
  cout << ans / 3 << endl;
  return 0;
}
