#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;
  vector<string> al(n);
  set<string> a;
  for (int i = 0; i < n; i++) {
    cin >> al[i];
    a.insert(al[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string s3 = "";
      for (int m = 0; m < k; m++) {
        if (al[i][m] == 'S' && al[j][m] == 'T') {
          s3 += 'E';
        }
        if (al[i][m] == 'S' && al[j][m] == 'S') {
          s3 += 'S';
        }
        if (al[i][m] == 'S' && al[j][m] == 'E') {
          s3 += 'T';
        }
        if (al[i][m] == 'E' && al[j][m] == 'E') {
          s3 += 'E';
        }
        if (al[i][m] == 'E' && al[j][m] == 'T') {
          s3 += 'S';
        }
        if (al[i][m] == 'E' && al[j][m] == 'S') {
          s3 += 'T';
        }
        if (al[i][m] == 'T' && al[j][m] == 'T') {
          s3 += 'T';
        }
        if (al[i][m] == 'T' && al[j][m] == 'S') {
          s3 += 'E';
        }
        if (al[i][m] == 'T' && al[j][m] == 'E') {
          s3 += 'S';
        }
      }
      if (a.find(s3) != a.end()) {
        ans++;
      }
    }
  }
  cout << ans / 3;
}
