#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
int n, k;
string find_third(const string a, const string b) {
  string s(k, 0);
  for (int i = 0; i < k; i++) {
    if (a[i] == b[i])
      s[i] = a[i];
    else {
      for (auto c : "SET") {
        if (c != a[i] and c != b[i]) {
          s[i] = c;
          break;
        }
      }
    }
  }
  return s;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(17);
  cin >> n >> k;
  vector<string> a(n);
  unordered_map<string, int> dict;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    dict[a[i]]++;
  }
  long long ans = 0;
  for (int j = 0; j < n; j++) {
    dict[a[j]]--;
    for (int i = 0; i < j; i++) {
      auto s = find_third(a[i], a[j]);
      if (dict.count(s)) ans += dict[s];
    }
  }
  cout << ans << endl;
  ;
  return 0;
}
