#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int n = 0ll, k = 0ll, res = 0ll;
  cin >> n >> k;
  vector<string> v(n);
  unordered_map<string, long long int> m;
  for (long long int i = 0ll; i < n; ++i) {
    cin >> v[i];
    ++m[v[i]];
  }
  string s(k, 'X');
  for (long long int i = 0ll; i < n; ++i) {
    for (long long int j = i + 1ll; j < n; ++j) {
      for (long long int l = 0ll; l < k; ++l) {
        if (v[i][l] == v[j][l])
          s[l] = v[i][l];
        else
          s[l] = 'S' ^ 'E' ^ 'T' ^ v[i][l] ^ v[j][l];
      }
      res += m.count(s);
    }
  }
  cout << (res / 3ll);
}
