#include <bits/stdc++.h>
using namespace std;
string s[2005];
map<string, int> m;
int main() {
  ios::sync_with_stdio(0);
  int n, k, ans = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    m[s[i]]++;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string t;
      for (int x = 0; x < k; x++) {
        if (s[i][x] == s[j][x])
          t += s[i][x];
        else if ((s[i][x] == 'S' && s[j][x] == 'E') ||
                 (s[i][x] == 'E' && s[j][x] == 'S'))
          t += "T";
        else if ((s[i][x] == 'E' && s[j][x] == 'T') ||
                 (s[i][x] == 'T' && s[j][x] == 'E'))
          t += "S";
        else if ((s[i][x] == 'T' && s[j][x] == 'S') ||
                 (s[i][x] == 'S' && s[j][x] == 'T'))
          t += "E";
      }
      ans += m[t];
    }
  }
  cout << ans / 3 << endl;
  return 0;
}
