#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return (y ? gcd(y, x % y) : x); }
long long lcm(long long x, long long y) { return x * (y / gcd(x, y)); }
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<string> a(n);
  set<string> s;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    s.insert(a[i]);
  }
  long long ans = 0ll;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string s1 = a[i];
      string s2 = a[j];
      string aux = "";
      for (int z = 0; z < k; z++) {
        if (s1[z] == s2[z])
          aux += s1[z];
        else {
          if (s1[z] != 'T' && s2[z] != 'T') aux += 'T';
          if (s1[z] != 'S' && s2[z] != 'S') aux += 'S';
          if (s1[z] != 'E' && s2[z] != 'E') aux += 'E';
        }
      }
      if (s.count(aux)) {
        ans++;
      }
    }
  }
  cout << ans / 3 << endl;
  return 0;
}
