require 'set'

loop do
  n = gets.chomp.to_i
  row_count = gets.chomp.to_i

  break if n == 0 && row_count == 0
  
  graph = Hash.new { |h, k| h[k] = [] }

  row_count.times do
    pair = gets.chomp.split(' ')
    graph[pair[0]] << pair[1]
    graph[pair[1]] << pair[0]
  end

  friends = graph['1']
  foaf = Set.new

  friends.each do |f|
    graph[f].each do |of|
      foaf.add(of) if of != '1'
    end
  end

  puts (friends | foaf.to_a).size
end