#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i2 = pair<int, int>;
using vi = vector<int>;
const int N = 1509;
string A[N], B[N * N];
string third(string a, string b) {
  int n = a.length();
  string res = "";
  for (int i = 0; i < n; i++) {
    if (a[i] == 'S' && b[i] == 'S')
      res += 'S';
    else if (a[i] == 'E' && b[i] == 'E')
      res += 'E';
    else if (a[i] == 'T' && b[i] == 'T')
      res += 'T';
    else if (a[i] != 'S' && b[i] != 'S')
      res += 'S';
    else if (a[i] != 'T' && b[i] != 'T')
      res += 'T';
    else if (a[i] != 'E' && b[i] != 'E')
      res += 'E';
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> A[i];
  int m = 0;
  for (int i = 1; i < n; i++) {
    for (int j = i + 1; j <= n; j++) B[++m] = third(A[i], A[j]);
  }
  sort(A + 1, A + n + 1);
  sort(B + 1, B + m + 1);
  int res = 0, a = 1, b = 1;
  while (a <= n && b <= m) {
    if (A[a] < B[b])
      a++;
    else if (A[a] > B[b])
      b++;
    else {
      res++;
      b++;
    }
  }
  cout << res / 3;
  return 0;
}
