#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T MIN(const T &a, const T &b) {
  return a < b ? a : b;
}
template <typename T>
inline T MAX(const T &a, const T &b) {
  return a > b ? a : b;
}
template <typename T, typename... Args>
inline T MIN(const T &a, const T &b, Args... args) {
  return MIN(MIN(a, b), args...);
}
template <typename T, typename... Args>
inline T MAX(const T &a, const T &b, Args... args) {
  return MAX(MAX(a, b), args...);
}
const double eps = 1e-8;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const int dir[4][2] = {-1, 0, 1, 0, 0, -1, 0, 1};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  map<string, int> mp;
  string s[1600];
  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    mp[s[i]]++;
  }
  auto judge = [](char a, char b) {
    if (a > b) swap(a, b);
    if (a == 'E' and b == 'S') return 'T';
    if (a == 'S' and b == 'T') return 'E';
    if (a == 'E' and b == 'T') return 'S';
  };
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      string res;
      for (int p = 0; p < k; p++) {
        if (s[i][p] == s[j][p]) {
          res += s[i][p];
          continue;
        }
        res += judge(s[i][p], s[j][p]);
      }
      ans += mp[res];
    }
  }
  cout << ans / 3 << '\n';
  return 0;
}
