#include <bits/stdc++.h>
using namespace std;
int tc;
void solve() {
  map<string, int> mp;
  vector<string> v;
  string s;
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    mp[s]++;
    if (mp[s] == 1) v.push_back(s);
  }
  int ans = 0;
  set<vector<string> > st;
  for (int i = 0; i < v.size(); i++) {
    vector<string> vv;
    if (mp[v[i]] >= 3) {
      vv.push_back(v[i]);
      vv.push_back(v[i]);
      vv.push_back(v[i]);
      st.insert(vv);
    }
    for (int j = i + 1; j < v.size(); j++) {
      string ss;
      for (int p = 0; p < k; p++) {
        if (v[i][p] == v[j][p])
          ss.push_back(v[i][p]);
        else if (v[i][p] != 'S' && v[j][p] != 'S')
          ss.push_back('S');
        else if (v[i][p] != 'E' && v[j][p] != 'E')
          ss.push_back('E');
        else
          ss.push_back('T');
      }
      if (mp[ss]) {
        vv.clear();
        vv.push_back(v[i]);
        vv.push_back(v[j]);
        vv.push_back(ss);
        sort(vv.begin(), vv.end());
        st.insert(vv);
      }
    }
  }
  cout << st.size() << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
  return 0;
}
