loop do
  n = gets.to_i
  m = gets.to_i
  break if n == 0
  r = []
  m.times { r << gets.split.map(&:to_i) }

  friends = r.select {|(a,b)| a == 1 || b == 1 }.map {|(a,b)| a == 1 ? b : a }
  foafs = r.select {|(a,b)| a != 1 && b != 1 && (friends.include?(a) || friends.include?(b)) }.flatten - friends

  puts friends.size + foafs.size
end