#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
string nc2i(char c1, char c2) {
  if (c1 == 'S') {
    if (c2 == 'E')
      return "T";
    else
      return "E";
  } else if (c1 == 'E') {
    if (c2 == 'S')
      return "T";
    else
      return "S";
  } else if (c1 == 'T') {
    if (c2 == 'E')
      return "S";
    else
      return "E";
  } else
    assert(false);
}
void solve() {
  int n;
  cin >> n;
  ;
  int k;
  cin >> k;
  ;
  vector<string> s(n);
  vector<vector<int> > f(k, vector<int>(3));
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  sort(s.begin(), s.end());
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n - 1; j++) {
      string se;
      for (int l = 0; l < k; l++) {
        if (s[i][l] == s[j][l])
          se += s[i][l];
        else
          se += nc2i(s[i][l], s[j][l]);
      }
      if (binary_search(s.begin() + j + 1, s.end(), se)) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}
int main() {
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  solve();
}
