#include <bits/stdc++.h>
using namespace std;
const int LM = 1504;
int N, K;
string arr[LM];
bool isExist(string tmp, int n1, int n2) {
  int lo = 1, hi = N, ans = N;
  while (lo <= hi) {
    int mid = (lo + hi) / 2;
    if (arr[mid] >= tmp)
      hi = mid - 1, ans = mid;
    else
      lo = mid + 1;
  }
  return (tmp == arr[ans]);
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 1; i <= N; i++) {
    cin >> arr[i];
  }
  sort(arr + 1, arr + N + 1);
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j < i; j++) {
      string tmp;
      for (int k = 0; k < K; k++) {
        if (arr[i][k] == arr[j][k])
          tmp.push_back(arr[i][k]);
        else
          tmp.push_back('S' + 'E' + 'T' - arr[i][k] - arr[j][k]);
      }
      if (tmp == arr[i] || tmp == arr[j]) continue;
      ans += isExist(tmp, i, j);
    }
  }
  printf("%d\n", ans / 3);
  return 0;
}
