#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, k;
  cin >> n >> k;
  string s[n + 1];
  set<string> ar;
  for (int x = 0; x < n; x++) {
    cin >> s[x];
    ar.insert(s[x]);
  }
  char a[3] = {'S', 'E', 'T'};
  long long int ans = 0;
  for (int x = 0; x < n; x++) {
    for (int y = x + 1; y < n; y++) {
      string d;
      for (int z = 0; z < k; z++) {
        if (s[x][z] == s[y][z]) {
          d += s[x][z];
        } else {
          for (int i = 0; i < 3; i++) {
            if (a[i] != s[x][z] && a[i] != s[y][z]) {
              d += a[i];
              break;
            }
          }
        }
      }
      if (d.length() != 0)
        if (ar.count(d)) ++ans;
    }
  }
  cout << ans / 3 << "\n";
}
