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})))

def s():

 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})))

if'__main__'==__name__:s()

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})))

def s():
    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})))


if "__main__" == __name__:
    s()

-import sys +def s(): +    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}))) +    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}))) + + +if "__main__" == __name__: +    s()