## main

loop do
  n = gets.strip.to_i
  break if n == 0

  m = gets.strip.to_i

  nbrs = n.times.map{[]}

  m.times do
    a, b = gets.strip.split(' ').map{|s| s.to_i - 1}
    nbrs[a] << b
    nbrs[b] << a
  end
  #p nbrs

  frds = n.times.map{nil}

  for f0 in nbrs[0]
    frds[f0] = true
    for f1 in nbrs[f0]
      frds[f1] = true if f1 != 0
    end
  end

  puts frds.compact.length
end