#include <bits/stdc++.h>
using namespace std;
string gets(string a, string b, long long k) {
  string res;
  for (long long i = 0; i < k; i++) {
    if (a[i] == b[i]) res += a[i];
    if (a[i] == 'S' && b[i] == 'E') res += 'T';
    if (a[i] == 'S' && b[i] == 'T') res += 'E';
    if (a[i] == 'E' && b[i] == 'S') res += 'T';
    if (a[i] == 'E' && b[i] == 'T') res += 'S';
    if (a[i] == 'T' && b[i] == 'E') res += 'S';
    if (a[i] == 'T' && b[i] == 'S') res += 'E';
  }
  return res;
}
void solve() {
  long long n, k, ans = 0;
  cin >> n >> k;
  vector<string> s(n);
  for (long long i = 0; i <= n - 1; i++) cin >> s[i];
  for (long long i = 0; i + 1 < n; i++) {
    set<string> ok;
    for (long long j = i + 1; j < n; j++) {
      string a = gets(s[i], s[j], k);
      if (ok.count(a))
        ans++;
      else
        ok.insert(s[j]);
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long tc = 1;
  while (tc--) solve();
}
