#include <bits/stdc++.h>
using namespace std;
auto clk = clock();
void solve() {
  long long n, k;
  cin >> n >> k;
  string s[n];
  map<string, long long> c;
  for (long long i = 0; i < n; i++) cin >> s[i];
  for (long long i = 0; i < n; i++) c[s[i]]++;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      string t = "";
      for (long long o = 0; o < k; o++) {
        if (s[i][o] == s[j][o])
          t += s[i][o];
        else
          t += ('S' + 'E' + 'T' - s[i][o] - s[j][o]);
      }
      if (c[t] > 0) ans++;
    }
  }
  cout << ans / 3 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(8);
  long long t = 1;
  while (t--) solve();
  return 0;
}
