#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
const long long modx = 998244353;
const long long per = 666013;
long long n, k, ans;
map<string, long long> q;
string s[1505];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  srand(chrono::steady_clock::now().time_since_epoch().count());
  cin >> n >> k;
  for (long long i = 1; i <= n; i++) cin >> s[i];
  q[s[1]]++;
  for (long long i = 2; i < n; i++) {
    for (long long j = i + 1; j <= n; j++) {
      string tz = "";
      for (long long t = 0; t < k; t++) {
        if (s[i][t] == s[j][t])
          tz.push_back(s[i][t]);
        else {
          if (s[i][t] == 'S' && s[j][t] == 'E') tz.push_back('T');
          if (s[i][t] == 'E' && s[j][t] == 'S') tz.push_back('T');
          if (s[i][t] == 'S' && s[j][t] == 'T') tz.push_back('E');
          if (s[i][t] == 'T' && s[j][t] == 'S') tz.push_back('E');
          if (s[i][t] == 'T' && s[j][t] == 'E') tz.push_back('S');
          if (s[i][t] == 'E' && s[j][t] == 'T') tz.push_back('S');
        }
      }
      ans += q[tz];
    }
    q[s[i]]++;
  }
  cout << ans;
}
