#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int INF = 0x3f3f3f3f;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ll n, k;
  cin >> n >> k;
  string arr[n];
  set<string> strs;
  for (int i = 0, ggd = n; i < ggd; i++) {
    cin >> arr[i];
    strs.insert(arr[i]);
  }
  ll ans = 0ll;
  string ss = "";
  for (int i = 0, ggd = n - 1; i < ggd; i++) {
    for (int j = (i + 1), ggd = n; j < ggd; j++) {
      for (int m = 0, ggd = k; m < ggd; m++) {
        if (arr[i][m] != arr[j][m]) {
          ss += ('S' + 'E' + 'T' - arr[i][m] - arr[j][m]);
        } else
          ss += arr[i][m];
      }
      if (strs.find(ss) != strs.end()) ans++;
      ss = "";
    }
  }
  cout << ans / 3;
  return 0;
}
