#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int ans = 0;
  for (int j = 0; j < n; j++) {
    map<string, int> mp;
    for (int l = j + 1; l < n; l++) {
      mp[s[l]]++;
    }
    for (int l = j + 1; l < n; l++) {
      mp[s[l]]--;
      string req(k, 'E');
      for (int i = 0; i < k; i++) {
        if (s[j][i] == s[l][i]) {
          req[i] = s[j][i];
        } else {
          if (s[j][i] == 'E') {
            req[i] = 'T';
            if (s[l][i] == 'T') {
              req[i] = 'S';
            }
          } else if (s[j][i] == 'T') {
            req[i] = 'E';
            if (s[l][i] == 'E') {
              req[i] = 'S';
            }
          } else {
            req[i] = 'E';
            if (s[l][i] == 'E') {
              req[i] = 'T';
            }
          }
        }
      }
      ans += mp[req];
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
