n,m = gets.chomp.split(" ").map(&:to_i)

friends = Hash.new{|hash,key| hash[key] = [] }

m.times do
  n1,n2 = gets.chomp.split(" ").map(&:to_i)
  friends[n1] << n2
  friends[n2] << n1
end

#p friends

max = 0
maxer = 0
n.times do |i|
  siz = friends[i+1].uniq.size
  if max < siz
    max = siz
    maxer = i+1
  end
end

up = []

friends[maxer].each do |e|
  friends[e].each do |f|
    up << f
  end
end

#puts("#{(friends[maxer]+up).uniq}")
puts("#{(friends[maxer]+up).uniq.size}")