ll n,l,c[1d6];int a[1d6],b[1d6],z;string s[1d3];wgraphg;{rd(n,l,s(n));rep(i,n)rep(j,n){a[z]=i;b[z]=j;c[z]+=s[i][0..l]!=s[j][0..l];z++;}g.setEdge(n,n*n,a,b,c);wt(g.MST_Prim_cost());}