#include <bits/stdc++.h>
using namespace std;
int n, m;
string s[1505];
unordered_set<string> st;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> s[i];
    st.insert(s[i]);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      string str = "";
      for (int k = 0; k < m; ++k) {
        char a = s[i][k];
        char b = s[j][k];
        if (a > b) swap(a, b);
        if (a != b) {
          if (a == 'E' && b == 'S')
            str += "T";
          else if (a == 'E' && b == 'T')
            str += "S";
          else if (a == 'S' && b == 'T')
            str += "E";
        } else if (a == b) {
          str += a;
        }
      }
      if (st.find(str) != st.end()) ++ans;
    }
  }
  cout << ans / 3 << "\n";
  return 0;
}
