#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const long long infLL = 9000000000000000000;
int dx[] = {0, 0, +1, -1};
int dy[] = {+1, -1, 0, 0};
template <typename first, typename second>
ostream &operator<<(ostream &os, const pair<first, second> &p) {
  return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}
template <typename first, typename second>
ostream &operator<<(ostream &os, const map<first, second> &v) {
  os << "[";
  for (auto it = v.begin(); it != v.end(); ++it) {
    if (it != v.begin()) os << ", ";
    os << it->first << " = " << it->second;
  }
  return os << "]";
}
clock_t tStart = clock();
void faltu() { cerr << endl; }
template <typename T>
void faltu(T a[], int n) {
  for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
  cerr << endl;
}
template <typename T, typename... hello>
void faltu(T arg, const hello &...rest) {
  cerr << arg << ' ';
  faltu(rest...);
}
long long factorial(long long n) {
  long long value = 1;
  for (long long i = 2; i <= n; i++) value *= i;
  return value;
}
long long ncr(long long n, long long r) {
  long long m = r, value = 1;
  for (int i = n; m >= 1; i--, m--) value *= i;
  return (value / factorial(r));
}
long long npr(long long n, long long p) {
  return factorial(n) / factorial(n - p);
}
string to_upper(string a) {
  for (int i = 0; i < (int)a.size(); ++i)
    if (a[i] >= 'a' && a[i] <= 'z') a[i] -= 'a' - 'A';
  return a;
}
string to_lower(string a) {
  for (int i = 0; i < (int)a.size(); ++i)
    if (a[i] >= 'A' && a[i] <= 'Z') a[i] += 'a' - 'A';
  return a;
}
long long sti(string a, int base = 10) {
  long long k = 0;
  for (int i = 0; i < (int)a.size(); ++i) {
    k *= base;
    k += a[i] - '0';
  }
  return k;
}
string toString(long long k, int base = 10) {
  if (k == 0) return "0";
  string a;
  while (k) {
    a.push_back((k % base) + '0');
    k /= base;
  }
  reverse(a.begin(), a.end());
  return a;
}
vector<string> v;
map<string, long long> mp;
void solve() {
  long long n, l;
  cin >> n >> l;
  string s;
  for (long long i = 0; i < n; i++) {
    cin >> s;
    v.push_back(s);
    mp[s]++;
  }
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 1; j < n; j++) {
      string s;
      for (long long k = 0; k < l; k++) {
        if (v[i][k] == v[j][k]) {
          s.push_back(v[i][k]);
        } else {
          if ((v[i][k] == 'E' && v[j][k] == 'T') ||
              (v[j][k] == 'E' && v[i][k] == 'T'))
            s.push_back('S');
          if ((v[i][k] == 'S' && v[j][k] == 'T') ||
              (v[j][k] == 'S' && v[i][k] == 'T'))
            s.push_back('E');
          if ((v[i][k] == 'E' && v[j][k] == 'S') ||
              (v[j][k] == 'E' && v[i][k] == 'S'))
            s.push_back('T');
        }
      }
      ans += mp[s];
      if (s == v[i]) ans--;
      if (s == v[j]) ans--;
    }
  }
  ans /= 3;
  cout << ans << "\n";
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
