#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::pair;
using std::string;
using std::vector;
using ll = long long;
const int INF = 1e9 + 1;
int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  std::set<vector<int>> s;
  vector<vector<int>> s1(n);
  for (int i = 0; i < n; ++i) {
    vector<int> v(k);
    for (int &j : v) {
      char c;
      cin >> c;
      if (c == 'S') j = 0;
      if (c == 'E') j = 1;
      if (c == 'T') j = 2;
    }
    s.insert(v);
    s1[i] = v;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = i + 1; j < n; ++j) {
      vector<int> v(k);
      for (int t = 0; t < k; ++t)
        if (s1[i][t] == s1[j][t])
          v[t] = s1[i][t];
        else
          v[t] = 3 - s1[i][t] - s1[j][t];
      if (s.find(v) != s.end()) ++ans;
    }
  cout << ans / 3;
  return 0;
}
