#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p = 1000000007) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
int32_t main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(chrono::high_resolution_clock::now().time_since_epoch().count());
  long long t = 1;
  while (t--) {
    long long n, k;
    cin >> n >> k;
    vector<string> v;
    for (long long i = 0; i < n; i++) {
      string s;
      cin >> s;
      v.push_back(s);
    }
    sort((v).begin(), (v).end());
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = i + 1; j < n; j++) {
        string str = "";
        for (long long c = 0; c < k; c++) {
          if (v[i][c] == v[j][c]) {
            str += v[i][c];
          } else {
            if ((v[i][c] == 'S' && v[j][c] == 'E') ||
                (v[i][c] == 'E' && v[j][c] == 'S')) {
              str += "T";
            } else if ((v[i][c] == 'S' && v[j][c] == 'T') ||
                       (v[j][c] == 'S' && v[i][c] == 'T')) {
              str += "E";
            } else {
              str += "S";
            }
          }
        }
        bool found = binary_search(v.begin(), v.end(), str);
        if (found) {
          ans++;
        }
      }
    }
    cout << (ans / 3) << "\n";
  }
  return 0;
}
