n,m=map(int,input().split()) e=[] for i in range(m): a,b=map(int,input().split()) a-=1 b-=1 e+=[(a,b)] def root(x): p=x l=[p] while r[p]!=p: p=r[p] l+=[p] for p in l: r[p]=l[-1] return r[x] def union(x,y): rx=root(x) ry=root(y) if rx==ry: return if rx>ry: rx,ry=ry,rx r[ry]=rx return r=list(range(n)) f=[0]*n for a,b in e[::-1]: ra=root(a) rb=root(b) p=min(ra,rb) if ra==rb: f[p]+=1 else: f[p]=max(f[ra],f[rb])+1 union(a,b) print(f[0])