Bees Alice and Alesya gave beekeeper Polina famous card game "Set" as a Christmas present. The deck consists of cards that vary in four features across three options for each kind of feature: number of shapes, shape, shading, and color. In this game, some combinations of three cards are said to make up a set. For every feature — color, number, shape, and shading — the three cards must display that feature as either all the same, or pairwise different. The picture below shows how sets look.

<image>

Polina came up with a new game called "Hyperset". In her game, there are n cards with k features, each feature has three possible values: "S", "E", or "T". The original "Set" game can be viewed as "Hyperset" with k = 4.

Similarly to the original game, three cards form a set, if all features are the same for all cards or are pairwise different. The goal of the game is to compute the number of ways to choose three cards that form a set.

Unfortunately, winter holidays have come to an end, and it's time for Polina to go to school. Help Polina find the number of sets among the cards lying on the table.

Input

The first line of each test contains two integers n and k (1 ≤ n ≤ 1500, 1 ≤ k ≤ 30) — number of cards and number of features.

Each of the following n lines contains a card description: a string consisting of k letters "S", "E", "T". The i-th character of this string decribes the i-th feature of that card. All cards are distinct.

Output

Output a single integer — the number of ways to choose three cards that form a set.

Examples

Input


3 3
SET
ETS
TSE


Output


1

Input


3 4
SETE
ETSE
TSES


Output


0

Input


5 4
SETT
TEST
EEET
ESTE
STES


Output


2

Note

In the third example test, these two triples of cards are sets:

  1. "SETT", "TEST", "EEET" 
  2. "TEST", "ESTE", "STES" 
#include <bits/stdc++.h>
using namespace std;
vector<long long int> primes;
bool specialPrimeNumbers(long long int n, long long int k) {
  for (long long int i = 0; i < primes.size(); i++) {
    for (long long int j = 0; j < i; j++) {
      if (primes[i] + primes[j] == n) {
        return true;
      }
    }
  }
  return false;
}
bool cmp(pair<int, int> p, pair<int, int> p1) { return p.first < p1.first; }
class edge {
 public:
  int a, b;
};
struct subset {
  int parent;
  int rank;
};
int find(struct subset subsets[], int i) {
  if (subsets[i].parent != i)
    subsets[i].parent = find(subsets, subsets[i].parent);
  return subsets[i].parent;
}
void Union(struct subset subsets[], int x, int y) {
  int xroot = find(subsets, x);
  int yroot = find(subsets, y);
  if (subsets[xroot].rank < subsets[yroot].rank)
    subsets[xroot].parent = yroot;
  else if (subsets[xroot].rank > subsets[yroot].rank)
    subsets[yroot].parent = xroot;
  else {
    subsets[yroot].parent = xroot;
    subsets[xroot].rank++;
  }
}
void dfs(vector<int> edges[], int a, int b, int visit[],
         map<int, vector<int>> &mp) {
  visit[a] = 1;
  for (auto i : edges[a]) {
    if (visit[i] == 1) {
      continue;
    } else {
      mp[b].push_back(i);
      dfs(edges, i, b + 1, visit, mp);
    }
  }
}
string result(string second) { return second; }
void simpleSieve(int limit) {
  bool mark[limit + 1];
  memset(mark, true, sizeof(mark));
  for (int p = 2; p * p < limit; p++) {
    if (mark[p] == true) {
      for (int i = p * 2; i < limit; i += p) mark[i] = false;
    }
  }
  for (int p = 2; p < limit; p++) {
    if (mark[p] == true) {
      primes.push_back(p);
    }
  }
}
void segmentedSieve(int n) {
  int limit = floor(sqrt(n)) + 1;
  simpleSieve(limit);
  int low = limit;
  int high = 2 * limit;
  while (low < n) {
    if (high >= n) high = n;
    bool mark[limit + 1];
    memset(mark, true, sizeof(mark));
    for (int i = 0; i < primes.size(); i++) {
      int loLim = floor(low / primes[i]) * primes[i];
      if (loLim < low) loLim += primes[i];
      for (int j = loLim; j < high; j += primes[i]) mark[j - low] = false;
    }
    for (int i = low; i < high; i++)
      if (mark[i - low] == true) primes.push_back(i);
    low = low + limit;
    high = high + limit;
  }
}
int dfs(vector<long long int> edges[], long long int &u, long long int v) {
  for (auto i : edges[u]) {
    if (i != v) {
      u = i;
      return 1;
    }
  }
  return 0;
}
int dfs1(vector<long long int> edges[], long long int &u, long long int v,
         map<int, int> &mp) {
  for (auto i : edges[u]) {
    if (i == v) {
      u = i;
      return 1;
    } else {
      if (mp.count(i) > 0) continue;
      u = i;
      mp.insert({i, 1});
    }
  }
  return 0;
}
long long int pairORSum(long long int arr[], int n) {
  long long int ans = 0;
  for (int i = 0; i < n; i++)
    for (int j = i + 1; j < n; j++) ans += arr[i] ^ arr[j];
  return ans % 1000000007;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int sumXOR(long long int arr[], long long int n) {
  long long int sum = 0;
  long long int zero[62] = {0}, one[62] = {0};
  long long int maxi = 0;
  for (int i = 0; i < n; i++) {
    long long int count = 0;
    while (count < 62) {
      if (arr[i] % 2 == 0) {
        zero[count]++;
      } else {
        one[count]++;
      }
      arr[i] = arr[i] / 2;
      maxi = max(count, maxi);
      count++;
    }
  }
  long long int ans = 0;
  for (int i = 0; i <= maxi; i++) {
    ans = (ans + ((zero[i] * one[i]) % 1000000007) * (power(2, i, 1000000007)) %
                     1000000007) %
          1000000007;
  }
  return ans;
}
long double distance(long long int x, long long int y, long long int x1,
                     long long int y1) {
  return (sqrt(pow(abs(x - x1), 2) + pow(abs(y - y1), 2)));
}
long double fact(int n) {
  if (n == 1) {
    return 1;
  }
  return n * fact(n - 1);
}
void solve1() {}
bool cmp1(pair<long long int, long long int> p,
          pair<long long int, long long int> p1) {
  return (p.second < p1.second);
}
long long int set_bit(long long int n) {
  long long int count = 0;
  while (n != 0) {
    if (n % 2 == 1) {
      count++;
    }
    n = n / 2;
  }
  return count;
}
long long int pow1(long long int a, long long int b) {
  if (b == 0) return 1;
  return a * pow1(a, b - 1);
}
long long int ans(string second[], int n, int m, int dp[], int curr, char flag,
                  char flag2) {
  return 0;
}
bool cmp2(string second, string s1) { return second.length() > s1.length(); }
int findMinLength(string arr[], int n) {
  int min = INT_MAX;
  for (int i = 0; i <= n - 1; i++)
    if (arr[i].length() < min) min = arr[i].length();
  return (min);
}
bool allContainsPrefix(string arr[], int n, string str, int start, int end) {
  for (int i = 0; i <= n - 1; i++)
    for (int j = start; j <= end; j++)
      if (arr[i][j] != str[j]) return (false);
  return (true);
}
string commonPrefix(string arr[], int n) {
  int index = findMinLength(arr, n);
  string prefix;
  int low = 0, high = index;
  while (low <= high) {
    int mid = low + (high - low) / 2;
    if (allContainsPrefix(arr, n, arr[0], low, mid)) {
      prefix = prefix + arr[0].substr(low, mid - low + 1);
      low = mid + 1;
    } else
      high = mid - 1;
  }
  return (prefix);
}
bool cmp4(pair<pair<long long int, long long int>, long long int> p,
          pair<pair<long long int, long long int>, long long int> p1) {
  return p.first.first < p1.first.first;
}
long long int sub_mod(long long int x, long long int y) {
  x -= y;
  if (x < 0) return x + 1000000007;
  return x;
}
long long int add_mod(long long int x, long long int y) {
  x += y;
  if (x >= 1000000007) return x - 1000000007;
  return x;
}
long long int multi_mod(long long int a, long long int b) {
  return (a * b) % 1000000007;
}
long long int gcdExtended(long long int a, long long int b, long long int *x,
                          long long int *y) {
  if (a == 0) {
    *x = 0, *y = 1;
    return b;
  }
  long long int x1, y1;
  long long int gcd = gcdExtended(b % a, a, &x1, &y1);
  *x = y1 - (b / a) * x1;
  *y = x1;
  return gcd;
}
long long int inv_mod2(long long int b, long long int m) {
  long long int x, y;
  long long int g = gcdExtended(b, m, &x, &y);
  if (g != 1) return -1;
  return (x % m + m) % m;
}
long long int inv_mod(long long int a) {
  long long int b = 1000000007, p = 1, q = 0;
  while (b) {
    long long int c = a / b, d = a;
    a = b;
    b = d % b;
    d = p;
    p = q;
    q = d - c * q;
  }
  return (p + 1000000007) % 1000000007;
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  string v[n];
  int i;
  map<string, int> mp;
  for (i = 0; i < n; i++) {
    cin >> v[i];
    mp[v[i]]++;
  }
  long long int res = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      string s1 = "";
      for (int z = 0; z < k; z++) {
        if (v[i][z] == v[j][z]) {
          s1 += v[i][z];
        } else {
          if (v[i][z] == 'S' && v[j][z] == 'E' ||
              (v[i][z] == 'E' && v[j][z] == 'S')) {
            s1 += "T";
          }
          if (v[i][z] == 'E' && v[j][z] == 'T' ||
              (v[i][z] == 'T' && v[j][z] == 'E')) {
            s1 += "S";
          }
          if (v[i][z] == 'T' && v[j][z] == 'S' ||
              (v[i][z] == 'S' && v[j][z] == 'T')) {
            s1 += "E";
          }
        }
      }
      res += mp[s1];
    }
  }
  cout << res / 3 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  for (int i = 0; i < t; i++) solve();
  return 0;
}
