program e;
const
  MaxN = 10000;
  MaxM = 1000000;
type 
   Edges=record
    a,b:integer;
   end;
var
  P, C: Integer;
  edge:array[1..MaxM] of Edges;
  
{  Con: array[1..MaxN, 1..MaxN] of Boolean;}
  Vxx:array[1..MaxN+1] of Integer;
  E:array[1..MaxM] of Integer;
  Z:array[1..MaxN+1] of Integer;
  
  Color, See: array[1..MaxN] of Integer;
  ActColor, MaxA, Parts: Integer;
  
  procedure Search(V: Integer);
  var
    I,J, A: Integer;
    
  begin
    Color[V]:= ActColor;
    ActColor:= ActColor + 1;
    See[V]:= Color[V];
    
    A:= 0;
{    for I:= 1 to P do}
    for J:=Vxx[V] to Vxx[V+1]-1 do
    begin
     I:=E[J];
{     Sousedi:=False;}
     
{    if Con[V, I] then }

{     if Sousedi then }
      if Color[I] = 0 then
      begin
        Search(I);
        if See[I] >= Color[V] then Inc(A) else 
        if See[V] > See[I] then See[V]:= See[I];
      end else
        if See[V] > Color[I] then See[V]:= Color[I];
    end;
    
    if Color[V] = 1 then A:= A - 1;
    if A > MaxA then MaxA:= A;
    
    {Writeln('Vrchol ', V, ' ', A);}
  end;
  
  procedure WriteState;
  var
    I: Integer;
  begin
    for I:= 1 to P do
    Writeln(I, ' ', Color[I], ' ', See[I]);
  end;
  
var  
  I,  X, Y: Integer;
begin
  while True do
  begin
    Readln(P, C);
    if P = 0 then Break;

    
{    for I:= 1 to P do
    for J:= 1 to P do
    Con[I, J]:= False;}
    
    for I:=1 to P+1 do Vxx[I]:=0;
    for I:=1 to C do E[I]:=0;
        
    for I:= 1 to C do
    begin
      Readln(X, Y);
      inc(x);
      inc(y);
      edge[i].a:=x;
      edge[i].b:=y;
      
      Inc(Vxx[x+1]);
      Inc(Vxx[y+1]);
      
{      Con[X + 1, Y + 1]:= True;
      Con[Y + 1, X + 1]:= True;}
    end;
    
    for I:=2 to P+1 do
    begin
     Inc(Vxx[I],Vxx[I-1]);
     Z[I]:=Vxx[I];
    end;
    
    for I:=1 to C do
    begin
     X:=edge[i].a;
     Y:=edge[i].b;
     E[Z[x]]:=y;
     E[Z[y]]:=x;
     Inc(Z[x]);
     Inc(Z[y]);
    end;
    
    for I:= 1 to P do Color[I]:= 0;
    
    MaxA:= 0;
    Parts:= 0;
    for I:= 1 to P do
    if Color[I] = 0 then 
    begin
      ActColor:= 1;
      Parts:= Parts + 1;
      Search(I);
    end;
    {WriteState;}
    
    Writeln(MaxA + Parts);
  end;
end.