while true
    n = gets.to_i
    m = gets.to_i
    break if [n, m] == [0, 0]
    h = Hash.new{|h, k| h[k] = []}
    m.times{
        a, b = gets.chomp.split.map(&:to_i)
        h[a] << b
        h[b] << a
    }
    friend = h[1].dup
    h[1].each{|x| h[x].each{|y| friend << y}}
    friend.delete(1)
    puts friend.uniq.length
end
