#include <bits/stdc++.h>
const int N = 3e5 + 5;
const long double pi = 3.141592653;
const long long mod = 1e9 + 9;
const long long MOD = 998244353;
const long long INF = 9223372036854775807LL;
using namespace std;
int dx[9] = {1, -1, 0, 0, 1, 1, -1, -1, 0};
int dy[9] = {0, 0, 1, -1, 1, -1, 1, -1, 0};
long long binexp(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b % 2) res = (res * a) % mod;
    a = (a * a) % mod;
    b = b / 2;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<string> v(n);
    set<long long> st;
    for (int i = 0; i < n; i++) {
      cin >> v[i];
      long long hash = 0;
      for (int j = 0; j < k; j++) {
        v[i][j] = v[i][j] + 32;
        hash += ((v[i][j] - 'a') * binexp(31, j)) % mod;
      }
      st.insert(hash);
    }
    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.push_back(v[i][l]);
          else {
            if (v[i][l] == 's' && v[j][l] == 'e')
              s.push_back('t');
            else if (v[i][l] == 's' && v[j][l] == 't')
              s.push_back('e');
            else if (v[i][l] == 'e' && v[j][l] == 't')
              s.push_back('s');
            else if (v[i][l] == 'e' && v[j][l] == 's')
              s.push_back('t');
            else if (v[i][l] == 't' && v[j][l] == 's')
              s.push_back('e');
            else if (v[i][l] == 't' && v[j][l] == 'e')
              s.push_back('s');
          }
        }
        long long hash = 0;
        for (int l = 0; l < k; l++)
          hash += ((s[l] - 'a') * binexp(31, l)) % mod;
        if (st.find(hash) != st.end()) ans++;
      }
    }
    cout << ans / 3;
  }
  return 0;
}
