#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n;
  cin >> k;
  vector<string> s(n);
  set<string> exist;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    exist.insert(s[i]);
  }
  long long int count = 0;
  for (int x = 0; x < n - 1; x++) {
    for (int y = x + 1; y < n; y++) {
      string temp = "";
      for (int i = 0; i < k; i++) {
        if (s[x][i] == s[y][i]) {
          temp += s[x][i];
        } else if ((s[x][i] == 'S' && s[y][i] == 'T') ||
                   (s[x][i] == 'T' && s[y][i] == 'S')) {
          temp += 'E';
        } else if ((s[x][i] == 'S' && s[y][i] == 'E') ||
                   (s[x][i] == 'E' && s[y][i] == 'S')) {
          temp += 'T';
        } else if ((s[x][i] == 'E' && s[y][i] == 'T') ||
                   (s[x][i] == 'T' && s[y][i] == 'E')) {
          temp += 'S';
        }
      }
      if (exist.find(temp) != exist.end()) {
        count++;
      }
    }
  }
  cout << count / 3 << endl;
  return 0;
}
