#include <bits/stdc++.h>
#pragma warning(disable : 4996)
FILE* _fin = stdin;
FILE* _fout = stdout;
void reversei(int* data, int n) {
  int k = n >> 1;
  for (int i = 0; i < k; ++i) {
    int tmp = data[i];
    data[i] = data[n - i - 1];
    data[n - i - 1] = tmp;
  }
}
int bsearch(int val, int* data, int n) {
  if (data[0] > val) return -1;
  if (data[n - 1] < val) return n;
  int l = 0;
  int r = n - 1;
  for (; l < r;) {
    int mid = (l + r + 1) >> 1;
    if (data[mid] <= val)
      l = mid;
    else
      r = mid - 1;
  }
  if (data[r] != val) ++r;
  return r;
}
struct Veci {
  int* data;
  int size;
  int n;
};
void init(Veci* t, int size) {
  t->data = (int*)malloc(sizeof(int) * size);
  t->size = size;
  t->n = 0;
}
void resize(Veci* t) {
  int ns = t->size * 1.2f;
  t->data = (int*)realloc(t->data, sizeof(int) * ns);
  t->size = ns;
}
void add(Veci* t, int val) {
  if (t->n >= t->size) resize(t);
  int k = t->n;
  t->data[k] = val;
  t->n = k + 1;
}
void free(Veci* t) {
  free(t->data);
  *t = {0};
}
struct Vecll {
  long long* data;
  int size;
  int n;
};
void init(Vecll* t, int size) {
  t->data = (long long*)malloc(sizeof(long long) * size);
  t->size = size;
  t->n = 0;
}
void resize(Vecll* t) {
  int ns = t->size * 1.2f;
  t->data = (long long*)realloc(t->data, sizeof(long long) * ns);
  t->size = ns;
}
void add(Vecll* t, long long val) {
  if (t->n >= t->size) resize(t);
  int k = t->n;
  t->data[k] = val;
  t->n = k + 1;
}
void free(Vecll* t) {
  free(t->data);
  *t = {0};
}
struct Vecs {
  char** data;
  int size;
  int n;
};
void init(Vecs* t, int size) {
  t->data = (char**)malloc(sizeof(char*) * size);
  t->size = size;
  t->n = 0;
}
void resize(Vecs* t) {
  int ns = t->size * 1.2f;
  t->data = (char**)realloc(t->data, sizeof(char*) * ns);
  t->size = ns;
}
void add(Vecs* t, char* val) {
  if (t->n >= t->size) resize(t);
  int k = t->n;
  t->data[k] = val;
  t->n = k + 1;
}
void free(Vecs* t) {
  free(t->data);
  *t = {0};
}
int ispali(int* a, int* b, int n) {
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[n - i - 1]) {
      return 0;
    }
  }
  return 1;
}
int ispalc(char* a, char* b, int n) {
  for (int i = 0; i < n; ++i) {
    if (a[i] != b[n - i - 1]) {
      return 0;
    }
  }
  return 1;
}
struct Pairi {
  int x, y;
};
int cmp_Pairi(const void* _a, const void* _b) {
  Pairi* a = (Pairi*)_a;
  Pairi* b = (Pairi*)_b;
  if (a->x == b->x) {
    if (a->y < b->y)
      return -1;
    else
      return 1;
  }
  if (a->x < b->x)
    return -1;
  else
    return 1;
}
void sort_Pairi(Pairi* d, int n) { qsort(d, n, sizeof(Pairi), cmp_Pairi); }
int cmp_Str(const void* _a, const void* _b) {
  char* a = *((char**)_a);
  char* b = *((char**)_b);
  return strcmp(a, b);
}
void sort_Str(char** str, int n) { qsort(str, n, sizeof(char*), cmp_Str); }
int main() {
  {
    _fin = fopen("data1287B.txt", "r");
    if (_fin == NULL) _fin = stdin;
  };
  int n, k;
  fscanf(_fin, "%d", &n);
  fscanf(_fin, "%d", &k);
  char** s = (char**)malloc(sizeof(char*) * 1501);
  for (int i = 0; i < n; ++i) {
    s[i] = (char*)malloc(sizeof(char) * 31);
    for (;;) {
      fgets(s[i], 31, _fin);
      if (s[i][0] != '\n') break;
    };
    s[i][k] = 0;
  }
  sort_Str(s, n);
  long long count = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      static char tmp[31];
      for (int c = 0; c < k; ++c) {
        if (s[i][c] == s[j][c])
          tmp[c] = s[i][c];
        else {
          char a = s[i][c];
          char b = s[j][c];
          if (a > b) {
            char t = a;
            a = b;
            b = t;
          };
          if (a == 'E' && b == 'S')
            tmp[c] = 'T';
          else if (a == 'E' && b == 'T')
            tmp[c] = 'S';
          else if (a == 'S' && b == 'T')
            tmp[c] = 'E';
        }
      }
      tmp[k] = 0;
      int left = j + 1;
      int right = n - 1;
      while (left < right) {
        int mid = (left + right + 1) >> 1;
        if (strcmp(s[mid], tmp) <= 0)
          left = mid;
        else
          right = mid - 1;
      }
      if (strcmp(s[right], tmp) == 0) {
        count++;
      }
    }
  }
  fprintf(_fout, "%lld\n", count);
  return 0;
}
