#include <bits/stdc++.h>
using namespace std;
inline long long add(long long a, long long b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
inline long long sub(long long a, long long b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
inline long long mul(long long a, long long b) {
  return (long long)((long long)a * b % 1000000007);
}
long long fast_power(long long base, long long power) {
  long long result = 1;
  while (power > 0) {
    if (power % 2 == 1) {
      result = (result * base);
    }
    base = (base * base);
    power = power / 2;
  }
  return result;
}
long long min(long long a, long long b) { return a > b ? b : a; }
long long max(long long a, long long b) { return a > b ? a : b; }
void SieveOfEratosthenes(long long n, set<long long> &s) {
  bool prime[n + 1];
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
  for (long long p = 2; p <= n; p++)
    if (prime[p]) s.insert(p * p);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  {
    long long n, k, ans = 0;
    cin >> n >> k;
    vector<string> s;
    unordered_set<string> us;
    string tmp;
    for (long long i = 0; i < n; i++) {
      cin >> tmp;
      s.push_back(tmp);
      us.insert(tmp);
    }
    for (long long i = 0; i < n - 1; i++) {
      for (long long j = i + 1; j < n; j++) {
        string s1 = s[i];
        for (long long m = 0; m < k; m++) {
          if (s[i][m] == s[j][m]) {
            s1[m] = s[i][m];
          } else if (s[i][m] != s[j][m]) {
            if (s[i][m] == 'S') {
              if (s[j][m] == 'E') {
                s1[m] = 'T';
              } else if (s[j][m] == 'T') {
                s1[m] = 'E';
              }
            } else if (s[i][m] == 'E') {
              if (s[j][m] == 'S') {
                s1[m] = 'T';
              } else if (s[j][m] == 'T') {
                s1[m] = 'S';
              }
            } else if (s[i][m] == 'T') {
              if (s[j][m] == 'S') {
                s1[m] = 'E';
              } else if (s[j][m] == 'E') {
                s1[m] = 'S';
              }
            }
          }
        }
        if (us.find(s1) != us.end()) {
          ans += 1;
        }
      }
    }
    cout << ans / 3 << "\n";
  }
}
