#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
constexpr int Dir4[4][2] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
constexpr int Dir8[8][2] = {{-1, -1}, {-1, 1}, {0, -1},
                            {0, 1},   {1, -1}, {1, 1}};
constexpr double EPS = 1e-8;
const double PI = acos(-1);
using int16 = short;
using uint16 = unsigned short;
using uint = unsigned int;
using int64 = long long;
using uint64 = unsigned long long;
using pii = pair<int, int>;
auto Equal = [](double a, double b) { return fabs(a - b) < EPS; };
constexpr int MAXN = 1500;
int n, k;
string s[MAXN + 1];
unordered_map<string, int64> UM;
unordered_map<char, int> convert;
int main() {
  convert['S'] = 1;
  convert['E'] = 2;
  convert['T'] = 4;
  convert[1] = 'S';
  convert[2] = 'E';
  convert[4] = 'T';
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int64 ans = 0;
  cin >> n >> k;
  for (int i = (0); i < (n); ++i) {
    cin >> s[i];
    ++UM[s[i]];
  }
  for (int i = (0); i < (n); ++i) {
    for (int j = (i + 1); j < (n); ++j) {
      string tmp = "";
      for (int k = (0); k < (s[i].size()); ++k)
        if (s[i][k] == s[j][k])
          tmp += s[i][k];
        else {
          int x = convert[s[i][k]] | convert[s[j][k]];
          tmp += convert[(~x) & 7];
        }
      ans += UM[tmp];
    }
  }
  cout << ans / 3;
  return 0;
}
