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