#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int INF = 1e18 + 7;
const int MOD = 1e9 + 7;
int64_t n, k, ans;
string a[1505];
unordered_map<string, bool> m;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int32_t i = 0; i < (n); ++i) {
    cin >> a[i];
    m[a[i]] = true;
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      string temp;
      for (int z = 0; z < k; z++) {
        if (a[i][z] == a[j][z])
          temp += a[i][z];
        else {
          if (a[i][z] != 'S' && a[j][z] != 'S') temp += 'S';
          if (a[i][z] != 'E' && a[j][z] != 'E') temp += 'E';
          if (a[i][z] != 'T' && a[j][z] != 'T') temp += 'T';
        }
      }
      if (m[temp] > 0) {
        ans++;
      }
    }
  }
  cout << ans / 3 << endl;
}
