#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve() {
  int n, k;
  cin >> n >> k;
  map<vector<int>, int> M;
  int arr[n][k];
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    vector<int> v;
    for (int j = 0; j < k; j++) {
      if (s[j] == 'S') arr[i][j] = 0;
      if (s[j] == 'E') arr[i][j] = 1;
      if (s[j] == 'T') arr[i][j] = 2;
      v.push_back(arr[i][j]);
    }
    M[v]++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      vector<int> v;
      if (i == j) continue;
      for (int m = 0; m < k; m++) {
        if (arr[i][m] == arr[j][m]) {
          v.push_back(arr[i][m]);
        } else {
          if (arr[i][m] == 0 && arr[j][m] == 1 ||
              arr[i][m] == 1 && arr[j][m] == 0)
            v.push_back(2);
          if (arr[i][m] == 0 && arr[j][m] == 2 ||
              arr[i][m] == 2 && arr[j][m] == 0)
            v.push_back(1);
          if (arr[i][m] == 2 && arr[j][m] == 1 ||
              arr[i][m] == 1 && arr[j][m] == 2)
            v.push_back(0);
        }
      }
      ans += M[v];
    }
  }
  cout << ans / 3 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tests = 1;
  while (tests--) {
    solve();
  }
}
