#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return !b ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
map<string, int> used;
vector<string> a;
int n, k;
char get_c(char c1, char c2) {
  if (c1 == c2) return c1;
  if (c1 > c2) {
    char t = c1;
    c1 = c2;
    c2 = t;
  }
  if (c1 == 'E' && c2 == 'S') return 'T';
  if (c1 == 'E' && c2 == 'T') return 'S';
  return 'E';
}
void solve() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    a.push_back(s);
    used[s] = i;
  }
  map<string, int>::iterator it;
  int cnt = 0;
  for (int i = 0; i < n - 1; i++)
    for (int j = i + 1; j < n; j++) {
      string s1 = a[i], s2 = a[j];
      char s[100];
      for (int t = 0; t < k; t++) {
        s[t] = get_c(s1[t], s2[t]);
      }
      s[k] = 0;
      string ss = s;
      it = used.find(ss);
      if (it != used.end() && it->second > j) cnt++;
    }
  cout << cnt;
}
int main() { solve(); }
