while True:

  n = int(eval(input()))

  if not n:

    break

  m = int(eval(input()))

  edge = [[0 for i in range(n + 1)] for j in range(n + 1)]

  for i in range(m):

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

    edge[a][b] = 1

    edge[b][a] = 1

  friends1 = [i for i in range(n + 1) if edge[1][i]]

  friends2 = []

  for friend in friends1:

    friends_lst = [i for i in range(n + 1) if edge[friend][i]]

    friends2.extend(friends_lst)

  ans = len(set(friends1 + friends2))

  if ans:

    ans -= 1

  print(ans)



def solve():

  while True:

    n = int(eval(input()))

    if not n:

      break

    m = int(eval(input()))

    edge = [[0 for i in range(n + 1)] for j in range(n + 1)]

    for i in range(m):

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

      edge[a][b] = 1

      edge[b][a] = 1

    friends1 = [i for i in range(n + 1) if edge[1][i]]

    friends2 = []

    for friend in friends1:

      friends_lst = [i for i in range(n + 1) if edge[friend][i]]

      friends2.extend(friends_lst)

    ans = len(set(friends1 + friends2))

    if ans:

      ans -= 1

    print(ans)

solve()  

while True:
    n = int(eval(input()))
    if not n:
        break
    m = int(eval(input()))
    edge = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for i in range(m):
        a, b = list(map(int, input().split()))
        edge[a][b] = 1
        edge[b][a] = 1
    friends1 = [i for i in range(n + 1) if edge[1][i]]
    friends2 = []
    for friend in friends1:
        friends_lst = [i for i in range(n + 1) if edge[friend][i]]
        friends2.extend(friends_lst)
    ans = len(set(friends1 + friends2))
    if ans:
        ans -= 1
    print(ans)

def solve():
    while True:
        n = int(eval(input()))
        if not n:
            break
        m = int(eval(input()))
        edge = [[0 for i in range(n + 1)] for j in range(n + 1)]
        for i in range(m):
            a, b = list(map(int, input().split()))
            edge[a][b] = 1
            edge[b][a] = 1
        friends1 = [i for i in range(n + 1) if edge[1][i]]
        friends2 = []
        for friend in friends1:
            friends_lst = [i for i in range(n + 1) if edge[friend][i]]
            friends2.extend(friends_lst)
        ans = len(set(friends1 + friends2))
        if ans:
            ans -= 1
        print(ans)


solve()

-while True: -    n = int(eval(input())) -    if not n: -        break -    m = int(eval(input())) -    edge = [[0 for i in range(n + 1)] for j in range(n + 1)] -    for i in range(m): -        a, b = list(map(int, input().split())) -        edge[a][b] = 1 -        edge[b][a] = 1 -    friends1 = [i for i in range(n + 1) if edge[1][i]] -    friends2 = [] -    for friend in friends1: -        friends_lst = [i for i in range(n + 1) if edge[friend][i]] -        friends2.extend(friends_lst) -    ans = len(set(friends1 + friends2)) -    if ans: -        ans -= 1 -    print(ans) +def solve(): +    while True: +        n = int(eval(input())) +        if not n: +            break +        m = int(eval(input())) +        edge = [[0 for i in range(n + 1)] for j in range(n + 1)] +        for i in range(m): +            a, b = list(map(int, input().split())) +            edge[a][b] = 1 +            edge[b][a] = 1 +        friends1 = [i for i in range(n + 1) if edge[1][i]] +        friends2 = [] +        for friend in friends1: +            friends_lst = [i for i in range(n + 1) if edge[friend][i]] +            friends2.extend(friends_lst) +        ans = len(set(friends1 + friends2)) +        if ans: +            ans -= 1 +        print(ans) + + +solve()