#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string str[n];
  map<string, int> mp;
  for (int i = 0; i < n; i++) {
    cin >> str[i];
    mp[str[i]]++;
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (i == j) continue;
      string x = "";
      for (int l = 0; l < k; l++) {
        char a = str[i][l], b = str[j][l];
        if (a == 'S') {
          if (b == 'S')
            x += 'S';
          else if (b == 'E')
            x += 'T';
          else
            x += 'E';
        } else if (a == 'E') {
          if (b == 'E')
            x += 'E';
          else if (b == 'S')
            x += 'T';
          else
            x += 'S';
        } else {
          if (b == 'T')
            x += 'T';
          else if (b == 'E')
            x += 'S';
          else
            x += 'E';
        }
      }
      int m = 0;
      if (x == str[i]) m++;
      if (x == str[j]) m++;
      if (mp[x]) cnt += (mp[x] - m);
    }
  }
  cout << cnt / 3 << endl;
  return 0;
}
