{
TASK:man
LANG:PASCAL
}
program man;
  const max=150;
  var A:array[0..max,0..max]of Boolean;
      Pos:array[0..max]of Byte;
      com:array[0..max]of Integer;
      D:array[0..max]of Boolean;
      m,i,j,x,y,br,no:Integer;
  procedure DFS(v:Integer);
    begin
      pos[v]:=1;
      for i:=1 to max do
        if (a[v,i]=true) and (pos[i]=0) and (i<>v) then
          begin
            pos[i]:=1;
            inc(com[j]);
            DFS(i);
          end;
    end;
  begin
    for i:=0 to max do
      d[i]:=false;
    readln(m);
      for i:=1 to max do
        for j:=1 to max do
          a[i,j]:=false;
      for i:=1 to max do
        pos[i]:=0;
      for i:=1 to max do
        com[i]:=1;
      for i:=1 to m do
        begin
          readln(x,y);
          a[x,y]:=true;
          a[y,x]:=true;
          d[x]:=true;
          d[y]:=true;
        end;
      for i:=1 to m do
        begin
          for j:=1 to m do
            write(a[i,j],' ');
          writeln;
        end;
      no:=0;
      for j:=0 to max do
       if pos[j]=0 then
         DFS(j);
      br:=0;
      for i:=0 to max do
        if d[i]=true then
          inc(br);
      for i:=0 to max do
        if com[i]>1 then
          begin
            inc(no);
          end;
      writeln(br-no);
   end.