#include <bits/stdc++.h>
long long mod = 1000000007;
long long mod2 = 998244353;
long long OO = 1e18;
long long david_villa_pow(long long x, long long n) {
  if (n == 0) return 1;
  long long u = david_villa_pow(x, n / 2);
  u = ((u) * (u));
  if (n % 2 == 1) u = ((u) * (x));
  return u;
}
long long up(long long x, long long y) {
  if (x % y == 0) return x / y;
  return x / y + 1;
}
using namespace std;
map<string, long long> mp[2000];
map<string, long long>::iterator it;
string s[2000];
int main() {
  long long i, j;
  ;
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, m;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = n - 1; i >= 0; i--) {
    for (it = mp[i + 1].begin(); it != mp[i + 1].end(); it++)
      mp[i][it->first] = it->second;
    mp[i][s[i]]++;
  }
  long long res = 0;
  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      string x;
      for (int k = 0; k < m; k++) {
        if (s[i][k] == s[j][k])
          x.push_back(s[i][k]);
        else {
          bool S = 0, T = 0, E = 0;
          if (s[i][k] == 'S' || s[j][k] == 'S') S = 1;
          if (s[i][k] == 'T' || s[j][k] == 'T') T = 1;
          if (s[i][k] == 'E' || s[j][k] == 'E') E = 1;
          if (!E) x.push_back('E');
          if (!T) x.push_back('T');
          if (!S) x.push_back('S');
        }
      }
      if (j + 1 < n) res += mp[j + 1][x];
      x.clear();
    }
  }
  cout << res << endl;
  return 0;
}
