#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const long long int ths = 1LL << 40;
const int NN = 5e3 + 6;
void pre() { return; }
long long int dp[1505][1505];
void solve() {
  long long int n, k;
  cin >> n >> k;
  string s[n];
  unordered_map<string, long long int> ma;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    ma[s[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string t = "";
      if (dp[i][j] || dp[j][i]) continue;
      for (int x = 0; x < k; x++) {
        if (s[i][x] == s[j][x]) {
          t += s[i][x];
        } else {
          set<char> ini;
          if (s[i][x] == 'S' && s[j][x] == 'E')
            t += 'T';
          else if (s[i][x] == 'E' && s[j][x] == 'S')
            t += 'T';
          else if (s[i][x] == 'S' && s[j][x] == 'T')
            t += 'E';
          else if (s[i][x] == 'T' && s[j][x] == 'S')
            t += 'E';
          else if (s[i][x] == 'E' && s[j][x] == 'T')
            t += 'S';
          else if (s[i][x] == 'T' && s[j][x] == 'E')
            t += 'S';
        }
      }
      long long int x = -1;
      if (ma.count(t)) x = ma[t];
      if (x != i && x != j && x != -1) {
        dp[i][j] = 1;
        dp[j][i] = 1;
        dp[i][x] = 1;
        dp[x][i] = 1;
        dp[j][x] = dp[x][j] = 1;
        ans++;
      }
    }
  }
  cout << ans;
  cout << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
