#include <bits/stdc++.h>
using namespace std;
map<string, long long> M;
int main() {
  int n, k;
  cin >> n >> k;
  vector<string> v;
  for (int i = 0; i < n; i++) {
    string x;
    cin >> x;
    v.push_back(x);
  }
  long long c = 0;
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 1; j < v.size(); j++) {
      string ans = "";
      for (int m = 0; m < k; m++) {
        if (v[i][m] == v[j][m])
          ans += v[i][m];
        else {
          if (v[i][m] == 'S' && v[j][m] == 'T' ||
              v[i][m] == 'T' && v[j][m] == 'S')
            ans += 'E';
          else if (v[i][m] == 'E' && v[j][m] == 'T' ||
                   v[i][m] == 'T' && v[j][m] == 'E')
            ans += 'S';
          else
            ans += 'T';
        }
      }
      c += M[ans];
    }
    M[v[i]]++;
  }
  cout << c;
}
