#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  string sub;
  for (int i = 0; i < k; i++) {
    sub.push_back('k');
  }
  long long int count = 0;
  set<string> arra;
  for (int i = 0; i < n; i++) {
    string a;
    cin >> a;
    arra.insert(a);
  }
  set<string>::iterator it1, it2;
  for (it1 = arra.begin(); it1 != arra.end(); it1++) {
    for (it2 = arra.begin(); it2 != arra.end(); it2++) {
      string a = *it1;
      string b = *it2;
      if (a != b) {
        for (int i = 0; i < k; i++) {
          if (a[i] == b[i]) {
            sub[i] = a[i];
          } else if ((a[i] == 'S' && b[i] == 'T') ||
                     (a[i] == 'T' && b[i] == 'S')) {
            sub[i] = 'E';
          } else if ((a[i] == 'S' && b[i] == 'E') ||
                     (a[i] == 'E' && b[i] == 'S')) {
            sub[i] = 'T';
          } else if ((a[i] == 'E' && b[i] == 'T') ||
                     (a[i] == 'T' && b[i] == 'E')) {
            sub[i] = 'S';
          }
        }
        if (arra.find(sub) != arra.end()) {
          count++;
        }
      }
    }
  }
  cout << count / 6 << endl;
}
