#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    long long n, k, ans = 0, ans2 = 0;
    cin >> n >> k;
    vector<string> v;
    map<string, long long> m;
    map<string, long long>::iterator p1, p2;
    for (long long i = 0; i < n; ++i) {
      string s;
      cin >> s;
      v.push_back(s);
      m[s]++;
    }
    for (p1 = m.begin(); p1 != m.end(); ++p1) {
      if ((p1->second) >= 3) {
        long long t = p1->second;
        ans2 += ((t * (t - 1) * (t - 2)) / 6);
      }
    }
    for (p1 = m.begin(); p1 != m.end(); ++p1) {
      p1++;
      if (p1 == m.end()) {
        break;
      }
      p2 = p1;
      p1--;
      for (; p2 != m.end(); p2++) {
        string u, v, w = "";
        u = p1->first;
        v = p2->first;
        for (long long i = 0; i < u.size(); ++i) {
          if (u[i] == v[i]) {
            w += v[i];
          } else if ((u[i] == 'S' && v[i] == 'T') ||
                     (v[i] == 'S' && u[i] == 'T')) {
            w += 'E';
          } else if ((u[i] == 'S' && v[i] == 'E') ||
                     (v[i] == 'S' && u[i] == 'E')) {
            w += 'T';
          } else {
            w += 'S';
          }
        }
        if (m.find(w) != m.end()) {
          ans += (m[u] * m[v] * m[w]);
        }
      }
    }
    ans /= 3;
    cout << ans + ans2 << '\n';
  }
  return 0;
}
