#include <bits/stdc++.h>
using namespace std;
const unsigned long long mod = 1e9 + 7;
template <class S, class T>
ostream& operator<<(ostream& os, const pair<S, T> v) {
  os << "(" << v.first << ", " << v.second << ")";
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<T> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << " ";
    }
    os << v[i];
  }
  return os;
}
template <class T>
ostream& operator<<(ostream& os, const vector<vector<T>> v) {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i > 0) {
      os << endl;
    }
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, k;
  cin >> n >> k;
  vector<string> s(n);
  for (int i = 0; i < (int)n; ++i) cin >> s[i];
  unordered_map<string, long long> mp;
  for (int i = 0; i < (int)n; ++i) mp[s[i]]++;
  long long res1 = 0;
  for (auto x : mp) {
    long long val = x.second;
    res1 += val * (val - 1) * (val - 2) / 6;
  }
  long long res2 = 0;
  for (int i = 0; i < (int)n; ++i) {
    for (int j = 0; j < (int)n; ++j) {
      if (i > j) continue;
      if (s[i] == s[j]) continue;
      string t = "";
      for (int l = 0; l < (int)k; ++l) {
        vector<char> moji(2);
        moji[0] = s[i][l];
        moji[1] = s[j][l];
        if (moji[0] > moji[1]) swap(moji[0], moji[1]);
        if (moji[0] == 'E' && moji[1] == 'S')
          t += 'T';
        else if (moji[0] == 'E' && moji[1] == 'T')
          t += 'S';
        else if (moji[0] == 'S' && moji[1] == 'T')
          t += 'E';
        else if (moji[0] == 'S' && moji[1] == 'S')
          t += 'S';
        else if (moji[0] == 'E' && moji[1] == 'E')
          t += 'E';
        else if (moji[0] == 'T' && moji[1] == 'T')
          t += 'T';
      }
      res2 += mp[t];
    }
  }
  res2 /= 3;
  cout << res1 + res2 << endl;
  return 0;
}
