#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n >> m;
  map<string, long> ma;
  vector<string> v;
  for (long i = 0; i < n; i++) {
    string a;
    cin >> a;
    v.push_back(a);
    ma[a] = 1;
  }
  long k = 0;
  long count = 0;
  for (long i = 0; i < n - 1; i++) {
    for (long j = i + 1; j < n; j++) {
      long ck = 0;
      string c = "";
      for (long h = 0; h < m; h++) {
        if (v[i][h] == v[j][h]) {
          c += v[i][h];
        } else {
          c += char('S' + 'E' + 'T' - v[i][h] - v[j][h]);
        }
      }
      if (ck == 0) {
        if (ma[c] == 1) count++;
      }
    }
  }
  cout << count / 3 << endl;
  return 0;
}
