#include <bits/stdc++.h>
using namespace std;
string s[1505];
char d[4] = {'S', 'E', 'T'};
string f(string a, string b) {
  string ans;
  for (int i = 0; i < a.length(); i++) {
    if (a[i] == b[i])
      ans += a[i];
    else {
      for (int j = 0; j < 3; j++) {
        if (d[j] != a[i] && d[j] != b[i]) {
          ans += d[j];
          break;
        }
      }
    }
  }
  return ans;
}
map<string, bool> mp;
int main() {
  int cnt = 0;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> s[i], mp[s[i]] = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      string t = f(s[i], s[j]);
      if (t != s[i] && t != s[j] && mp[t]) {
        cnt++;
      }
    }
  }
  cout << cnt / 3;
  return 0;
}
