#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
int n, k;
string s[1505];
int main() {
  while (cin >> n >> k) {
    map<string, long long> m;
    for (int i = 0; i < n; i++) cin >> s[i], m[s[i]]++;
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      m[s[i]]--;
      for (int j = i + 1; j + 1 < n; j++) {
        m[s[j]]--;
        string ss;
        for (int z = 0; z < k; z++) {
          if ((s[i][z] == s[j][z])) {
            ss += s[i][z];
          } else {
            if (s[i][z] != 'S' && s[j][z] != 'S') ss += 'S';
            if (s[i][z] != 'E' && s[j][z] != 'E') ss += 'E';
            if (s[i][z] != 'T' && s[j][z] != 'T') ss += 'T';
          }
        }
        if (m.find(ss) != m.end()) {
          ans += m[ss];
        }
      }
      for (int j = i + 1; j + 1 < n; j++) m[s[j]]++;
    }
    cout << ans << endl;
  }
}
