#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, k;
  cin >> n >> k;
  map<string, long long> s;
  string a[n];
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    s[a[i]] = i + 1;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      char p[k];
      for (long long l = 0; l < k; l++) {
        if (a[i][l] == a[j][l]) {
          p[l] = a[i][l];
          continue;
        }
        if (a[i][l] == 'S' || a[j][l] == 'S') {
          if (a[i][l] == 'E' || a[j][l] == 'E')
            p[l] = 'T';
          else
            p[l] = 'E';
        } else
          p[l] = 'S';
      }
      string ps(p);
      if (s[ps.substr(0, k)] > j + 1) {
        ans++;
      }
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long T = 1;
  while (T--) solve();
  return 0;
}
