#include <bits/stdc++.h>
using namespace std;
map<vector<int>, int> ma;
signed main() {
  int n, k;
  cin >> n >> k;
  vector<string> a;
  for (int i = 0; i < n; ++i) {
    string s;
    vector<int> now;
    cin >> s;
    a.push_back(s);
    for (int j = 0; j < k; ++j) {
      if (s[j] == 'S')
        now.push_back(0);
      else if (s[j] == 'E')
        now.push_back(1);
      else
        now.push_back(2);
    }
    ma[now]++;
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      vector<int> now;
      for (int uk = 0; uk < k; ++uk) {
        if (a[i][uk] == a[j][uk]) {
          if (a[i][uk] == 'S')
            now.push_back(0);
          else if (a[i][uk] == 'E')
            now.push_back(1);
          else
            now.push_back(2);
        } else {
          int summ = 0;
          if (a[i][uk] == 'S')
            summ += 0;
          else if (a[i][uk] == 'E')
            summ += 1;
          else
            summ += 2;
          if (a[j][uk] == 'S')
            summ += 0;
          else if (a[j][uk] == 'E')
            summ += 1;
          else
            summ += 2;
          now.push_back(3 - summ);
        }
      }
      if (ma.find(now) != ma.end()) ans += ma[now];
    }
  }
  cout << ans / 3 << endl;
}
