#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<string> s(n);
  for (int i = 0; i < (int)n; ++i) cin >> s[i];
  map<string, long long> mp;
  for (int i = 0; i < (int)n; ++i) mp[s[i]]++;
  long long res = 0;
  for (int i = 0; i < (int)n; ++i) {
    for (int j = 0; j < (int)n; ++j) {
      if (i > j) continue;
      if (s[i] == s[j]) {
        res += max(mp[s[i]] - 2, 0ll);
      } else {
        string t = "";
        for (int l = 0; l < (int)k; ++l) {
          char x1 = s[i][l];
          char x2 = s[j][l];
          if (s[i][l] == 'E' && s[j][l] == 'T') t += 'S';
          if (s[i][l] == 'S' && s[j][l] == 'T') t += 'E';
          if (s[i][l] == 'E' && s[j][l] == 'S') t += 'T';
          if (s[i][l] == 'T' && s[j][l] == 'E') t += 'S';
          if (s[i][l] == 'T' && s[j][l] == 'S') t += 'E';
          if (s[i][l] == 'S' && s[j][l] == 'E') t += 'T';
          if (s[i][l] == 'S' && s[j][l] == 'S') t += 'S';
          if (s[i][l] == 'E' && s[j][l] == 'E') t += 'E';
          if (s[i][l] == 'T' && s[j][l] == 'T') t += 'T';
        }
        res += mp[t];
      }
    }
  }
  cout << res / 3 << endl;
  assert(res % 3 == 0);
  return 0;
}
