#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    map<string, long long> mpp;
    string s[n];
    for (long long i = 0; i <= n - 1; i++) {
      cin >> s[i];
      mpp[s[i]]++;
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = i + 1; j < n; j++) {
        string s1 = s[i], s2 = s[j];
        string s3;
        long long ck = 0;
        for (long long r = 0; r <= k - 1; r++)
          if (s1[r] == s2[r])
            s3.push_back(s1[r]);
          else {
            if (s2[r] != 'S' and s1[r] != 'S')
              s3.push_back('S');
            else if (s2[r] != 'E' and s1[r] != 'E')
              s3.push_back('E');
            else if (s2[r] != 'T' and s1[r] != 'T')
              s3.push_back('T');
          }
        if (mpp.find(s3) != mpp.end()) {
          ans++;
        }
      }
    }
    cout << ans / 3 << "\n";
  }
  return 0;
}
