#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  if (n < 3) {
    cout << 0;
    return 0;
  }
  vector<string> a(n);
  unordered_map<string, bool> gg;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    gg[a[i]] = 1;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      string need;
      for (int x = 0; x < k; ++x) {
        if (a[i][x] == a[j][x]) {
          need += a[i][x];
        } else {
          if ((a[i][x] == 'S' || a[j][x] == 'S') &&
              (a[i][x] == 'E' || a[j][x] == 'E')) {
            need += 'T';
          }
          if ((a[i][x] == 'E' || a[j][x] == 'E') &&
              (a[i][x] == 'T' || a[j][x] == 'T')) {
            need += 'S';
          }
          if ((a[i][x] == 'S' || a[j][x] == 'S') &&
              (a[i][x] == 'T' || a[j][x] == 'T')) {
            need += 'E';
          }
        }
      }
      ans += gg[need];
    }
  }
  cout << ans / 3;
  return 0;
}
