#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  string s[n];
  set<string> store;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    store.insert(s[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    set<string> v;
    store.erase(s[i]);
    for (int j = i + 1; j < n; j++) {
      v.insert(s[j]);
      store.erase(s[j]);
      string temp;
      for (int l = 0; l < k; l++) {
        if (s[i][l] == s[j][l]) {
          temp += s[i][l];
        } else {
          temp += ('S' + 'E' + 'T' - s[i][l] - s[j][l]);
        }
      }
      if (store.find(temp) != store.end()) {
        cnt++;
        v.insert(temp);
        store.erase(temp);
      }
    }
    for (auto it : v) {
      store.insert(it);
    }
  }
  cout << cnt << "\n";
}
