#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  set<string> srt;
  long long n, kk, ans = 0;
  cin >> n >> kk;
  string s[1550];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    srt.insert(s[i]);
  }
  sort(s, s + n);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string tr = "";
      for (int k = 0; k < kk; k++) {
        if (s[i][k] == s[j][k])
          tr += s[i][k];
        else if ((s[i][k] == 'S' && s[j][k] == 'T') ||
                 (s[i][k] == 'T' && s[j][k] == 'S'))
          tr += 'E';
        else if ((s[i][k] == 'S' && s[j][k] == 'E') ||
                 (s[i][k] == 'E' && s[j][k] == 'S'))
          tr += 'T';
        else if ((s[i][k] == 'E' && s[j][k] == 'T') ||
                 (s[i][k] == 'T' && s[j][k] == 'E'))
          tr += 'S';
      }
      if (srt.find(tr) != srt.end()) ans++;
    }
  }
  cout << ans / 3;
}
