#include <bits/stdc++.h>
using namespace std;
const long long md = 1e9 + 7;
const int N = 1600;
const int M = 5100;
string ss[N];
map<string, int> mp;
string fun(int a, int b, int k) {
  string sa = ss[a], sb = ss[b];
  string ret = sa;
  for (int i = 0; i < k; i++) {
    if (sa[i] == sb[i])
      ret[i] = sa[i];
    else {
      int s = 1, e = 1, t = 1;
      if (sa[i] == 'S' || sb[i] == 'S') s = 0;
      if (sa[i] == 'E' || sb[i] == 'E') e = 0;
      if (sa[i] == 'T' || sb[i] == 'T') t = 0;
      if (s == 1) ret[i] = 'S';
      if (e == 1) ret[i] = 'E';
      if (t == 1) ret[i] = 'T';
    }
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  int i, j, k;
  int u, v, w;
  int a, b, c, d;
  int z;
  cin >> n >> k;
  mp.clear();
  for (i = 0; i < n; i++) {
    cin >> ss[i];
    mp[ss[i]] = i;
  }
  int num = 0;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      string a = fun(i, j, k);
      if (mp.find(a) != mp.end()) {
        int id = mp[a];
        if (id > j) num++;
      }
    }
  }
  cout << num << endl;
  return 0;
}
