#include <bits/stdc++.h>
using namespace std;
const int sieve_size = 15000002;
bool sieve[sieve_size + 1];
vector<long long> prime;
void Sieve() {
  prime.push_back(2);
  for (int i = 3; i * i <= sieve_size; i += 2) {
    if (!sieve[i]) {
      long long p = i * 2;
      for (int j = i * i; j <= sieve_size; j += p) {
        sieve[j] = true;
      }
    }
  }
  for (int i = 3; i <= sieve_size; i += 2) {
    if (!sieve[i]) prime.push_back(i);
  }
}
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
inline int GA(long long n, vector<long long>& vec) {
  for (int i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    vec.push_back(x);
  }
  return 0;
}
inline int GAEG(long long m, vector<long long> vec[]) {
  for (int i = 0; i < m; ++i) {
    long long x, y;
    cin >> x >> y;
    x--, y--;
    vec[x].push_back(y);
    vec[y].push_back(x);
  }
  return 0;
}
bool isvalid(long long xx, long long yy, long long n, long long m) {
  return (xx >= 0 && xx < n && yy >= 0 && yy < m);
}
long long pw(long long x, long long y, long long dr) {
  if (y == 0) return 1;
  long long o = y / 2;
  long long f = pw(x, o, dr) % dr;
  if (y % 2) {
    return (((f * f) % dr) * x) % dr;
  } else
    return (f * f) % dr;
}
map<string, long long> mp;
map<pair<char, char>, char> qq;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long n, m;
  cin >> n >> m;
  qq[make_pair('S', 'T')] = 'E';
  qq[make_pair('T', 'S')] = 'E';
  qq[make_pair('E', 'T')] = 'S';
  qq[make_pair('T', 'E')] = 'S';
  qq[make_pair('S', 'E')] = 'T';
  qq[make_pair('E', 'S')] = 'T';
  vector<string> ss;
  for (int i = 0; i < n; ++i) {
    string x;
    cin >> x;
    mp[x]++;
    ss.push_back(x);
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      string s = "";
      for (int k = 0; k < m; ++k) {
        if (ss[i][k] != ss[j][k])
          s += qq[make_pair(ss[i][k], ss[j][k])];
        else
          s += ss[i][k];
      }
      if (mp[s] > 0) ans++;
    }
  }
  cout << ans / 3 << endl;
  return 0;
}
