#include <bits/stdc++.h>
using namespace std;
const int maxn = 1600;
map<string, int> mp;
string s[maxn];
void AC() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  int res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = i + 1; j <= n; j++) {
      string tmp = "";
      for (int q = 0; q < k; q++) {
        if (s[i][q] == s[j][q])
          tmp += s[i][q];
        else
          tmp += 'S' + 'E' + 'T' - s[i][q] - s[j][q];
      }
      if (mp.count(tmp)) res += mp[tmp];
    }
  cout << res / 3 << endl;
}
int main() {
  AC();
  return 0;
}
