ll@N;string@S[N];setA;rep[S](s,N)rep[S](t,N)if(s!=t)A.insert(s+t),A.insert(t+s);wt(N=A.size());