#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1510;
int n, m;
map<string, int> mapa;
string niz[MAXN];
long long int rj = 0;
string f(string a, string b) {
  string ret;
  for (int i = (0); i < (m); i++) {
    if (a[i] == b[i]) {
      ret.push_back(a[i]);
      continue;
    }
    char c = (char)('S' + 'E' + 'T' - a[i] - b[i]);
    ret.push_back(c);
  }
  return ret;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (n); i++) cin >> niz[i];
  for (int i = (0); i < (n); i++) {
    for (int j = (i + 1); j < (n); j++) {
      string s = f(niz[i], niz[j]);
      rj += mapa[s];
    }
    mapa[niz[i]]++;
  }
  cout << rj << endl;
  return 0;
}
