loop do
  n = gets.chomp.to_i
  m = gets.chomp.to_i
  break if n == 0 && m == 0

  friend = []
  relation = []
  m.times do |i|
    relation << gets.chomp.split(" ").map(&:to_i)
    #p relation
    friend << relation[i][1] if relation[i][0] == 1
    frined << relation[i][0] if relation[i][1] == 1
  end
  #p friend
  if friend == []
    #puts "hoge"
    puts 0
    next
  end
  fFriend = []
  friend.each do |x|
    relation.each do |y|
      fFriend << y[1] if x == y[0] && y[1] != 1
      fFriend << y[0] if x == y[1] && y[0] != 1
    end
  end
  totFriend = friend + fFriend
  puts totFriend.uniq.length
end

