N,M,*P = $<.read.split.map &:to_i
A = [[]]*(N+1)
m = 0
M.times {|i|
  r,a = [],P[i+i,2]
  x,y = a.map {|i;j| (r<< i; i=j) while (j=A[i])[0]; r<< i; i}.sort
  g,h = [A[x],A[y]].map{|h| h.empty? ? a.to_h{[_1,0]} : h}.sort_by{_1.size}
  h.merge! g  if h.object_id != g.object_id
  r.each {A[_1] = y}
  A[y] = h
  m < h.size && m = h.size
}
p m