#include <bits/stdc++.h>
using namespace std;
template <class T>
void read(T &x) {
  x = 0;
  register char c = getchar();
  register bool f = 0;
  while (!isdigit(c)) f ^= c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  if (f) x = -x;
}
template <class T>
void print(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) print(x / 10);
  putchar('0' + x % 10);
}
void rd() {}
const int N = 1509;
int T, n, m, ans;
unordered_map<string, int> mp;
string str[N];
int main() {
  rd();
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) cin >> str[i], mp[str[i]] = true;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      string s = "";
      for (int k = 0; k < m; k++) {
        if (str[i][k] == 'S' && str[j][k] == 'S')
          s += 'S';
        else if (str[i][k] == 'T' && str[j][k] == 'T')
          s += 'T';
        else if (str[i][k] == 'E' && str[j][k] == 'E')
          s += 'E';
        else if (str[i][k] == 'S' && str[j][k] == 'T')
          s += 'E';
        else if (str[i][k] == 'T' && str[j][k] == 'S')
          s += 'E';
        else if (str[i][k] == 'E' && str[j][k] == 'T')
          s += 'S';
        else if (str[i][k] == 'T' && str[j][k] == 'E')
          s += 'S';
        else if (str[i][k] == 'S' && str[j][k] == 'E')
          s += 'T';
        else if (str[i][k] == 'E' && str[j][k] == 'S')
          s += 'T';
      }
      if (mp[s]) ans++;
    }
  }
  printf("%d\n", ans / 3);
  return 0;
}
