#include <bits/stdc++.h>
const long long int M = 1000000007;
const double pi = 3.1415926;
using namespace std;
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fastio();
  int n, k;
  cin >> n >> k;
  string s[n];
  unordered_map<string, int> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    m[s[i]] = 1;
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      string g;
      if (i != j) {
        for (int l = 0; l < k; l++) {
          g += s[i][l] == s[j][l] ? s[i][l]
                                  : 'S' + 'T' + 'E' - s[i][l] - s[j][l];
        }
        auto it = m.find(g);
        if (it != m.end()) c++;
      }
    }
  }
  cout << c / 6;
  return 0;
}
