#include <bits/stdc++.h>
using namespace std;
inline bool checkBit(int n, int i) { return n & ((int)1 << i); }
inline int setBit(int n, int i) {
  return n | ((int)1 << i);
  ;
}
inline int resetBit(int n, int i) { return n & (~((int)1 << i)); }
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(int year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long int &a) { a = (a + 1000000007) % 1000000007; }
inline int modMul(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline int modAdd(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline int modSub(long long int a, long long int b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline int modPow(long long int b, long long int p) {
  int r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline int modInv(int a) { return modPow(a, 1000000007 - 2); }
inline int modDiv(int a, int b) { return modMul(a, modInv(b)); }
inline int fact(int r) {
  int ans = 1;
  while (r) ans = modMul(ans, r), r--;
  return ans;
}
inline int invfact(int r) {
  int ans = 1;
  while (r) ans = modMul(ans, modInv(r)), r--;
  return ans;
}
inline double dgcd(double a, double b) {
  if (a < b) return dgcd(b, a);
  if (b < .0001) return a;
  return dgcd(b, fmod(a, b));
}
const int N = 5e3 + 1;
long long int power(long long int base, long long int exp) {
  long long int res = 1;
  while (exp > 0) {
    if (exp % 2 == 1) res = (res * base) % 1000000007;
    base = (base * base) / 1000000007;
    exp /= 2;
  }
  return res % 1000000007;
}
void hacked() {
  long long int n, k;
  cin >> n >> k;
  string s[n];
  for (long long int i = 0; i < n; i++) cin >> s[i];
  sort(s, s + n);
  long long int ans = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = i + 1; j < n; j++) {
      string t = "";
      for (long long int l = 0; l < k; l++) {
        if (s[i][l] == s[j][l])
          t += s[i][l];
        else {
          if ((s[i][l] == 'S' || s[i][l] == 'E') &&
              (s[j][l] == 'S' || s[j][l] == 'E'))
            t += 'T';
          else if ((s[i][l] == 'S' || s[i][l] == 'T') &&
                   (s[j][l] == 'S' || s[j][l] == 'T'))
            t += 'E';
          else
            t += 'S';
        }
      }
      long long int l = j + 1;
      long long int u = n - 1;
      while (l <= u) {
        long long int d = (l + u) / 2;
        if (s[d] > t) {
          u = d - 1;
        } else if (s[d] == t) {
          ans++;
          break;
        } else
          l = d + 1;
      }
    }
  }
  cout << ans;
}
signed main() {
  int test = 1;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  while (test--) hacked();
  return 0;
}
