#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const long long MOD = 1e9 + 7;
using namespace std;
long long n_bits(long long n) {
  long long x = __builtin_popcount(n);
  return x;
}
char get(char x, char y) {
  if ((x == 'S' and y == 'E') or (x == 'E' and y == 'S')) return 'T';
  if ((x == 'S' and y == 'T') or (x == 'T' and y == 'S')) return 'E';
  return 'S';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  map<string, long long> m;
  long long n, k, count = 0;
  cin >> n >> k;
  string v[n];
  for (int i = 0; i < (n); ++i) {
    cin >> v[i];
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = i + 1; j < (n); ++j) {
      string s = "";
      for (int l = 0; l < (k); ++l) {
        if (v[i][l] == v[j][l]) {
          s += v[i][l];
        } else {
          s += get(v[i][l], v[j][l]);
        }
      }
      count += m[s];
    }
    m[v[i]]++;
  }
  cout << count << endl;
  return 0;
}
