#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<string> v(n);
  map<string, int> M;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    M[v[i]]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string s;
      for (int p = 0; p < k; p++) {
        bool f = v[i][p] == v[j][p] ? 1 : 0;
        if (f == 1) {
          s.push_back(v[i][p]);
        } else {
          if (v[i][p] != 'S' and v[j][p] != 'S')
            s.push_back('S');
          else if (v[i][p] != 'E' and v[j][p] != 'E')
            s.push_back('E');
          else
            s.push_back('T');
        }
      }
      ans += M[s];
    }
  }
  cout << ans / 3 << "\n";
}
