#include <bits/stdc++.h>
using namespace std;
void printi(vector<int> &l) {
  for (long long i = 0; i < l.size(); ++i) {
    cout << l[i] << " ";
  }
  cout << endl;
}
void printl(vector<long long> &l) {
  for (long long i = 0; i < l.size(); ++i) {
    cout << l[i] << " ";
  }
  cout << endl;
}
template <class T>
istream &operator>>(istream &in, vector<T> &arr) {
  for (T &i : arr) {
    in >> i;
  }
  return in;
}
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  unordered_map<string, long long> s;
  long long n, k;
  cin >> n >> k;
  vector<string> str;
  for (int i = 0; i < n; ++i) {
    string f;
    cin >> f;
    if (s.count(f) == 0) {
      s[f] = 0;
      str.push_back(f);
    }
    s[f] += 1;
  }
  long long ans = 0;
  for (int i = 0; i < str.size(); ++i) {
    for (int j = i + 1; j < str.size(); ++j) {
      string h = "";
      for (int p = 0; p < k; ++p) {
        if (str[i][p] == str[j][p]) {
          h.push_back(str[i][p]);
        } else {
          char uk = 'S' + 'E' + 'T';
          uk -= str[i][p];
          uk -= str[j][p];
          h.push_back(uk);
        }
      }
      if (s.count(h) == 0) s[h] = 0;
      ans += s[h];
    }
  }
  long long anss = ans / 3;
  for (auto o : s) {
    anss += (o.second * (o.second - 1) * (o.second - 2)) / 6;
  }
  cout << anss << endl;
}
