#include <bits/stdc++.h>
#define s first
#define cnt second
using namespace std;
typedef long long ll;
unordered_map<string,ll>a;
string s;
ll n,k,i,ans;
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
while(cin>>n>>k)
{
while(n--)cin>>s,a[s]++;
ans=0;
for(auto it=a.begin();it!=a.end();it++)
{
for(auto it2=a.begin();it2!=a.end();it2++)
{
if(it==it2)continue;
for(i=0;i<k;i++)
{
if(it->s[i]==it2->s[i])s[i]=it->s[i];
else if((it->s[i]=='S'&&it2->s[i]=='T')||(it->s[i]=='T'&&it2->s[i]=='S'))s[i]='E';
else if((it->s[i]=='S'&&it2->s[i]=='E')||(it->s[i]=='E'&&it2->s[i]=='S'))s[i]='T';
else if((it->s[i]=='E'&&it2->s[i]=='T')||(it->s[i]=='T'&&it2->s[i]=='E'))s[i]='S';
}
auto it3=a.find(s);
if(it3!=a.end()&&it3!=it&&it3!=it2)ans+=it->cnt*it2->cnt*it3->cnt;
}
}
cout<<ans/6<<'\n';
a.clear();
}
return 0;
}
519C - A and B and Team Training | 631A - Interview |
961B - Lecture Sleep | 522A - Reposts |
1166D - Cute Sequences | 1176A - Divide it |
1527A - And Then There Were K | 1618E - Singers' Tour |
1560B - Who's Opposite | 182B - Vasya's Calendar |
934A - A Compatible Pair | 1618F - Reverse |
1684C - Column Swapping | 57C - Array |
1713D - Tournament Countdown | 33A - What is for dinner |
810A - Straight A | 1433C - Dominant Piranha |
633A - Ebony and Ivory | 1196A - Three Piles of Candies |
299A - Ksusha and Array | 448B - Suffix Structures |
1092B - Teams Forming | 1166C - A Tale of Two Lands |
544B - Sea and Islands | 152B - Steps |
1174D - Ehab and the Expected XOR Problem | 1511A - Review Site |
1316A - Grade Allocation | 838A - Binary Blocks |