int n,l,a[1d6],b[1d6],z;ll c[1d6];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,1d6,a,b,c);wt(g.MST_Prim_cost());}