#include <bits/stdc++.h>
using namespace std;
namespace fastio {
template <class T>
istream &operator>>(istream &os, vector<T> &vec) {
  for (auto &u : vec) os >> u;
  return os;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (auto &u : vec) os << u << " ";
  return os;
}
template <class T1, class T2>
inline istream &operator>>(istream &os, pair<T1, T2> &p) {
  return os >> p.first >> p.second;
}
template <class T1, class T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  return os << p.first << " " << p.second;
}
template <class T>
ostream &operator<<(ostream &os, set<T> &con) {
  for (auto &u : con) os << u << " ";
  return os;
}
void re() {}
template <typename T, typename... args>
void re(T &x, args &...tail) {
  cin >> x;
  re(tail...);
}
void pr() {}
template <typename T>
void pr(const T &x) {
  cout << x;
}
template <typename T, typename... args>
void pr(const T &x, const args &...tail) {
  cout << x << " ";
  pr(tail...);
}
template <typename... args>
void prln(const args &...tail) {
  pr(tail...);
  cout << "\n";
}
}  // namespace fastio
using namespace fastio;
const long long int mod = 1e9 + 7;
const long long int mod1 = 998244353;
int main() {
  cin.sync_with_stdio(false);
  cin.exceptions(cin.failbit);
  cin.tie(0);
  long long int n, k;
  re(n, k);
  string s[n], s1;
  map<string, long long int> mp1;
  vector<pair<string, string>> vec;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    if (mp1.find(s[i]) == mp1.end()) mp1[s[i]] = 0;
    mp1[s[i]]++;
  }
  for (int i = 0; i + 1 < n; i++)
    for (int j = i + 1; j < n; j++) vec.push_back({s[i], s[j]});
  long long int cnt = 0;
  for (int i = 0; i < vec.size(); i++) {
    s1 = "";
    for (int j = 0; j < k; j++) {
      if (vec[i].first[j] == vec[i].second[j])
        s1 += vec[i].first[j];
      else
        s1 += char(106 - (vec[i].first[j] - 65) - (vec[i].second[j] - 65));
    }
    if (mp1.find(s1) == mp1.end()) continue;
    cnt += mp1[s1];
    if (s1 == vec[i].first) cnt -= 2;
  }
  prln(cnt / 3);
  return 0;
}
