loop do
  n = gets.to_i
  m = gets.to_i
  break if(n|m)==0
  hash = Hash.new{|hash,key|hash[key]=Array.new}
  m.times do
    a,b = gets.split.map(&:to_i)
    hash[a] << b
    hash[b] << a
  end
  friend=hash[1]
  if friend.empty?
    puts 0
    next
  end
  ans = friend.dup
  friend.each do |f|
    ans |=hash[f]
  end
  ans.delete(1)
  puts ans.size
end