#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int base = 1e9 + 7;
const int oo = 1e6 + 10;
const int gh = 1e3 + 3;
int n, m, k, q;
int a[oo];
string s[1505];
map<string, int> cnt;
void input() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> s[i];
  for (int i = 1; i <= n; i++) {
    cnt[s[i]]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      string t = "";
      for (int k = 0; k < m; k++) {
        if (s[i][k] == s[j][k])
          t += s[i][k];
        else
          t += char('S' + 'E' + 'T' - s[i][k] - s[j][k]);
      }
      ans += cnt[t];
    }
  }
  cout << ans / 3;
}
void cre() {}
void solve() { cre(); }
void ouput() {}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (ifstream("test.txt")) {
    freopen("test.txt", "r", stdin);
  } else if (ifstream(""
                      ".inp")) {
    freopen(
        ""
        ".inp",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  int t = 1;
  while (t--) {
    input();
    solve();
    ouput();
  }
}
