#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<string> arr(n);
  map<string, int> hashmap;
  string s1, s2, s3;
  bool flag;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    hashmap[arr[i]] = 1;
  }
  int ans = 0;
  for (int p = 0; p < n; p++) {
    s1 = arr[p];
    for (int q = p + 1; q < n; q++) {
      s2 = arr[q];
      s3 = "";
      for (int i = 0; i < k; i++) {
        if (s1[i] == s2[i])
          s3 += s1[i];
        else {
          if ((s1[i] == 'S' && s2[i] == 'E') || (s1[i] == 'E' && s2[i] == 'S'))
            s3 += 'T';
          else if ((s1[i] == 'E' && s2[i] == 'T') ||
                   (s1[i] == 'T' && s2[i] == 'E'))
            s3 += 'S';
          else if ((s1[i] == 'S' && s2[i] == 'T') ||
                   (s1[i] == 'T' && s2[i] == 'S'))
            s3 += 'E';
        }
      }
      if (hashmap[s3] == 1) ans += 1;
    }
  }
  cout << (ans / 3) << endl;
  return 0;
}
