#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  vector<string> v(n);
  map<string, long long> s;
  for (long long i = 0; i < n; ++i) {
    cin >> v[i];
    s[v[i]] = i;
  }
  long long ans = 0;
  for (long long i = 0; i < n; ++i) {
    for (long long j = i + 1; j < n; ++j) {
      vector<char> x(k);
      for (long long l = 0; l < k; l++) {
        if (v[i][l] == v[j][l])
          x[l] = v[i][l];
        else {
          if (v[i][l] == 'S' && v[j][l] == 'E') x[l] = 'T';
          if (v[i][l] == 'E' && v[j][l] == 'S') x[l] = 'T';
          if (v[i][l] == 'S' && v[j][l] == 'T') x[l] = 'E';
          if (v[i][l] == 'T' && v[j][l] == 'S') x[l] = 'E';
          if (v[i][l] == 'T' && v[j][l] == 'E') x[l] = 'S';
          if (v[i][l] == 'E' && v[j][l] == 'T') x[l] = 'S';
        }
      }
      string sp(x.begin(), x.end());
      if (s[sp] > j) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
