#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1e9 + 5;
const double eps = 1e-7;
const double PI = acos(-1.0);
inline void debug_vi(vector<int> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void debug_vll(vector<long long> a) {
  for (long long i = (long long)(0); i < (long long)(a.size()); i++)
    cout << a[i] << " ";
}
inline void print_case(int tn) { cout << "Case #" << tn << ": "; }
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T>
using maxpq = priority_queue<T>;
int n, k;
vector<string> arr;
set<string> s;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  clock_t clk = clock();
  cin >> n >> k;
  arr.resize(n);
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    cin >> arr[i];
    s.insert(arr[i]);
  }
  int res = 0;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    for (long long j = (long long)(i + 1); j < (long long)(n); j++) {
      string target;
      for (long long p = (long long)(0); p < (long long)(k); p++) {
        if (arr[i][p] == arr[j][p]) {
          target.push_back(arr[i][p]);
        } else {
          vector<char> options = {'S', 'E', 'T'};
          for (char c : options) {
            if (arr[i][p] == c || arr[j][p] == c) continue;
            target.push_back(c);
          }
        }
      }
      int minus = (target == arr[i]) + (target == arr[j]);
      res += s.count(target) - minus;
    }
  }
  cout << res / 3;
  cerr << "\n"
       << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC
       << "\n";
  return 0;
}
