ll n,l,z,m,d[1d6],e[1d6];string g[1d3];unionFind u;{rd(n,l,g(n));rep(j,n)rep(k,j)d[m]+=g[j][0..l]!=g[k][0..],e[m++]=j*n+k;sortA(m,d,e);u.walloc(n,1);z+=u(e[0..m]%n,e[0..]/n)*d[0..];wt(z);}