c,f:array[1..100050]of longint;
n,k,i,jia,x,y,d,t1,t2,p,q:longint;
function find(t:longint):longint;
begin
if f[t]=t then
find:=t
else
find:=find(f[t]);
end;
procedure cha(a,b:longint);
begin
p:=find(a);
q:=find(b);
f[q]:=p;
end;
begin
readln(n,k);
for i:=1 to n do
f[i]:=i;
for i:=1 to k do
begin
readln(d,x,y);
if (x>n) or (y>n) then
jia:=jia+1
else
if d=1 then
begin
t1:=find(x); t2:=find(y);
if (c[t1]=t2) or (c[t2]=t1) then
jia:=jia+1
else
cha(x,y);
end
else
begin
t1:=find(x);
t2:=find(y);
if (t1=t2) or (c[t1]=t2) then
jia:=jia+1
else
c[t2]:=t1;
end;
end;
writeln(jia);
end.
哪错了~!