di,f:array[1..1200]of longint;
x,y,t1,t2,i,h,n,m,p,q:longint;
ch:char;
function find(z:longint):longint;
begin
if f[z]=z then
find:=z
else
find:=find(f[z]);
end;
procedure cha(a,b:longint);
begin
q:=find(a);
p:=find(b);
f[q]:=p;
end;
begin
readln(n);
for i:=1 to n do
f[i]:=i;
readln(m);
for i:=1 to m do
begin
readln(ch,x,y);
if ch='E' then
begin
t1:=find(x); t2:=find(y);
if di[t1]=0 then
di[t1]:=t2
else
if di[t1]<>t2 then
cha(di[t1],t2);
if di[t2]=0 then
di[t2]:=t1
else
if di[t2]<>t1 then
cha(di[t2],t1);
end
else
cha(x,y);
end;
for i:=1 to n do
if f[i]=i then
h:=h+1;
writeln(h);
end.
为什么不对