while True:

    n, m = int(eval(input())), int(eval(input()))

    if m == 0:

        break

    d = {k+1:[] for k,_ in enumerate(range(m))}

    for _ in range(m):

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

        d[a].append(b)

        d[b].append(a)

    ans = d[1].copy()

    for k in d[1]:

        ans += d[k]

    print((len(set(ans))-1))
while True:

    n = int(eval(input()))

    m = int(eval(input()))

    if m == 0:

        break

    dataset = [input().split() for _ in range(m)]

    list_ = {i+1: [] for i in range(n)}

    for data in dataset:

        idx_x, idx_y = list(map(int, data))

        list_[idx_x].append(idx_y)

        list_[idx_y].append(idx_x)



    ans = list_[1].copy()

    for i in list_[1]:

        ans += list_[i]

    print((len(set(ans))-1))
while True:
    n, m = int(eval(input())), int(eval(input()))
    if m == 0:
        break
    d = {k + 1: [] for k, _ in enumerate(range(m))}
    for _ in range(m):
        a, b = list(map(int, input().split()))
        d[a].append(b)
        d[b].append(a)
    ans = d[1].copy()
    for k in d[1]:
        ans += d[k]
    print((len(set(ans)) - 1))

while True:
    n = int(eval(input()))
    m = int(eval(input()))
    if m == 0:
        break
    dataset = [input().split() for _ in range(m)]
    list_ = {i + 1: [] for i in range(n)}
    for data in dataset:
        idx_x, idx_y = list(map(int, data))
        list_[idx_x].append(idx_y)
        list_[idx_y].append(idx_x)
    ans = list_[1].copy()
    for i in list_[1]:
        ans += list_[i]
    print((len(set(ans)) - 1))

-    n, m = int(eval(input())), int(eval(input())) +    n = int(eval(input())) +    m = int(eval(input())) -    d = {k + 1: [] for k, _ in enumerate(range(m))} -    for _ in range(m): -        a, b = list(map(int, input().split())) -        d[a].append(b) -        d[b].append(a) -    ans = d[1].copy() -    for k in d[1]: -        ans += d[k] +    dataset = [input().split() for _ in range(m)] +    list_ = {i + 1: [] for i in range(n)} +    for data in dataset: +        idx_x, idx_y = list(map(int, data)) +        list_[idx_x].append(idx_y) +        list_[idx_y].append(idx_x) +    ans = list_[1].copy() +    for i in list_[1]: +        ans += list_[i]