#include <bits/stdc++.h>
using namespace std;
unordered_map<string, int> num;
set<string> st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string temp;
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    num[temp]++;
    st.insert(temp);
  }
  long long ans = 0;
  for (set<string>::iterator it1 = st.begin(); it1 != st.end(); it1++) {
    it1++;
    for (set<string>::iterator it2 = it1; it2 != st.end(); it2++) {
      it1--;
      string temp = *it1;
      for (int i = 0; i < k; i++) {
        if ((*it1)[i] != (*it2)[i]) {
          if ((*it1)[i] != 'S' && (*it2)[i] != 'S') temp[i] = 'S';
          if ((*it1)[i] != 'E' && (*it2)[i] != 'E') temp[i] = 'E';
          if ((*it1)[i] != 'T' && (*it2)[i] != 'T') temp[i] = 'T';
        }
      }
      ans = ans +
            (long long)num[*it1] * (long long)num[*it2] * (long long)num[temp];
      it1++;
    }
    it1--;
  }
  if (st.size() == 1) {
    cout << (long long)k * (long long)(k - 1) * (long long)(k - 2) / 6ll;
    return 0;
  }
  cout << ans / 3 << endl;
}
