#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int count = 0;
  map<string, long long int> mp;
  vector<string> str(n);
  for (long long int i = 0; i < n; i++) {
    cin >> str[i];
    mp[str[i]]++;
  }
  string set = "SET";
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i + 1; j < n; j++) {
      string out = "";
      for (long long int q = 0; q < k; q++) {
        if (str[i][q] == str[j][q]) {
          out += str[i][q];
        } else {
          for (long long int a = 0; a < 3; a++) {
            if (str[i][q] != set[a] && str[j][q] != set[a]) {
              out += set[a];
            }
          }
        }
      }
      count += mp[out];
    }
  }
  cout << count / 3;
}
