for e in iter(input,'0'):

 R=[[]for _ in[0]*-~int(e)]

 for _ in[0]*int(eval(input())):

  a,b=list(map(int,input().split()))

  R[a]+=[b];R[b]+=[a]

 for m in R[1][:]:R[1]+=R[m]

 print((len({*R[1]}-{1})))

import sys

r=sys.stdin.readline

for e in iter(r,'0\n'):

 R=[[]for _ in[0]*-~int(e)]

 for _ in[0]*int(r()):

  a,b=list(map(int,r().split()))

  R[a]+=[b];R[b]+=[a]

 for m in R[1][:]:R[1]+=R[m]

 print((len({*R[1]}-{1})))

for e in iter(input, "0"):
    R = [[] for _ in [0] * -~int(e)]
    for _ in [0] * int(eval(input())):
        a, b = list(map(int, input().split()))
        R[a] += [b]
        R[b] += [a]
    for m in R[1][:]:
        R[1] += R[m]
    print((len({*R[1]} - {1})))

import sys

r = sys.stdin.readline
for e in iter(r, "0\n"):
    R = [[] for _ in [0] * -~int(e)]
    for _ in [0] * int(r()):
        a, b = list(map(int, r().split()))
        R[a] += [b]
        R[b] += [a]
    for m in R[1][:]:
        R[1] += R[m]
    print((len({*R[1]} - {1})))

-for e in iter(input, "0"): +import sys + +r = sys.stdin.readline +for e in iter(r, "0\n"): -    for _ in [0] * int(eval(input())): -        a, b = list(map(int, input().split())) +    for _ in [0] * int(r()): +        a, b = list(map(int, r().split()))