#include <bits/stdc++.h>
using namespace std;
long long arr[2000000] = {0}, brr[2000000] = {0};
vector<string> vec;
string str;
long long mod = 1000000007;
unordered_map<string, long long> ump;
map<char, long long> mp;
map<string, long long> mp1;
map<long long, char> rmp;
set<long long> st;
stack<long long> stk;
long long fac(long long n) {
  long long i, prod = 1;
  for (i = 1; i <= n; i++) prod = ((i % mod) * (prod % mod)) % mod;
  return prod;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long whitecnt(long long x1, long long y1, long long x2, long long y2) {
  if (x1 == x2 && y1 == y2) {
    if ((x1 + y1) % 2 == 0)
      return 1;
    else
      return 0;
  }
  if (((x2 - x1 + 1) * (y2 - y1 + 1)) % 2 == 0)
    return ((x2 - x1 + 1) * (y2 - y1 + 1)) / 2;
  else {
    if ((x1 + y1) % 2 == 0)
      return ((x2 - x1 + 1) * (y2 - y1 + 1)) / 2 + 1;
    else
      return ((x2 - x1 + 1) * (y2 - y1 + 1)) / 2;
  }
}
void intersect(long long x1, long long y1, long long x2, long long y2,
               long long x3, long long y3, long long x4, long long y4,
               vector<long long>& tempvec) {
  long long x5 = max(x1, x3);
  long long y5 = max(y1, y3);
  long long x6 = min(x2, x4);
  long long y6 = min(y2, y4);
  if (x5 <= x6 && y5 <= y6) {
    tempvec.push_back(x5);
    tempvec.push_back(y5);
    tempvec.push_back(x6);
    tempvec.push_back(y6);
  }
}
string func(string str1, string str2, long long k) {
  string tempstr = "";
  for (long long i = 0; i < k; i++) {
    if (str1[i] != str2[i])
      tempstr += rmp[3 - (mp[str1[i]] + mp[str2[i]])];
    else
      tempstr += str1[i];
  }
  return tempstr;
}
int main() {
  long long x, y, i, j, k, n, m, num, temp, fn,
      cnt = 0, d, l, r, flag = 0, sum1 = 0, a, b, len1 = 0, t, mx = LLONG_MIN,
      mn = LLONG_MAX, ind;
  long long x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6;
  string tempstr;
  scanf("%lld %lld", &n, &len1);
  mp['E'] = 0;
  mp['S'] = 1;
  mp['T'] = 2;
  rmp[0] = 'E';
  rmp[1] = 'S';
  rmp[2] = 'T';
  for (i = 0; i < n; i++) {
    cin >> str;
    vec.push_back(str);
    ump[str]++;
    mp1[str] = i;
  }
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n - 1; j++) {
      tempstr = func(vec[i], vec[j], len1);
      if (ump.find(tempstr) != ump.end() && mp1[tempstr] > j) cnt++;
    }
  }
  for (auto x : ump) {
    num = x.second;
    cnt += (num * (num - 1) * (num - 2)) / 6;
  }
  printf("%lld\n", cnt);
  return 0;
}
