n,m=list(map(int,input().split()))

xy = [list(map(int, input().split())) for _ in range(m)]

l=[1]*n

out_=[0]*n

in_=[0]*n#入れられたことがある履歴。0番目だけは初期値1

c=1

#print(in_)

check=0

for i in range(m):

    if check==0:

        if xy[i][0]==1:#箱1に入ってくる前に初めて箱1から赤いボールを移す場合

            in_[xy[i][1]-1]+=1

            check=1

        else:#箱１から赤いボールを移す前に白いボールが入ってくる場合

            if xy[i][1]==1:

                in_[xy[i][1]-1]+=1

                check=1

        l[xy[i][0]-1]-=1

        l[xy[i][1]-1]+=1

        #print(l,in_)

    else:

        l[xy[i][0]-1]-=1

        l[xy[i][1]-1]+=1

        if l[xy[i][0]-1]==0 and in_[xy[i][0]-1]!=0:#移した後、空になる場合

            in_[xy[i][0]-1]=0

            in_[xy[i][1]-1]+=1

        elif l[xy[i][0]-1]!=0 and in_[xy[i][0]-1]!=0:#移した後、残っている場合

            in_[xy[i][1]-1]+=1

        #print(l,in_)

#print(l,in_)

ans=0

for i in range(n):

    if in_[i]!=0:

        ans+=1

print(ans)
n,m=list(map(int,input().split()))

xy = [list(map(int, input().split())) for _ in range(m)]

l=[1]*n

out_=[0]*n

in_=[0]*n

c=1



check=0

for i in range(m):

    if check==0:

        if xy[i][0]==1:

            in_[xy[i][1]-1]+=1

            check=1

        else:

            if xy[i][1]==1:

                in_[xy[i][1]-1]+=1

                check=1

        l[xy[i][0]-1]-=1

        l[xy[i][1]-1]+=1

    else:

        l[xy[i][0]-1]-=1

        l[xy[i][1]-1]+=1

        if l[xy[i][0]-1]==0 and in_[xy[i][0]-1]!=0:

            in_[xy[i][0]-1]=0

            in_[xy[i][1]-1]+=1

        elif l[xy[i][0]-1]!=0 and in_[xy[i][0]-1]!=0:

            in_[xy[i][1]-1]+=1

ans=0

for i in range(n):

    if in_[i]!=0:

        ans+=1

print(ans)
n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]
l = [1] * n
out_ = [0] * n
in_ = [0] * n  # 入れられたことがある履歴。0番目だけは初期値1
c = 1
# print(in_)
check = 0
for i in range(m):
    if check == 0:
        if xy[i][0] == 1:  # 箱1に入ってくる前に初めて箱1から赤いボールを移す場合
            in_[xy[i][1] - 1] += 1
            check = 1
        else:  # 箱１から赤いボールを移す前に白いボールが入ってくる場合
            if xy[i][1] == 1:
                in_[xy[i][1] - 1] += 1
                check = 1
        l[xy[i][0] - 1] -= 1
        l[xy[i][1] - 1] += 1
        # print(l,in_)
    else:
        l[xy[i][0] - 1] -= 1
        l[xy[i][1] - 1] += 1
        if l[xy[i][0] - 1] == 0 and in_[xy[i][0] - 1] != 0:  # 移した後、空になる場合
            in_[xy[i][0] - 1] = 0
            in_[xy[i][1] - 1] += 1
        elif l[xy[i][0] - 1] != 0 and in_[xy[i][0] - 1] != 0:  # 移した後、残っている場合
            in_[xy[i][1] - 1] += 1
        # print(l,in_)
# print(l,in_)
ans = 0
for i in range(n):
    if in_[i] != 0:
        ans += 1
print(ans)

n, m = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]
l = [1] * n
out_ = [0] * n
in_ = [0] * n
c = 1
check = 0
for i in range(m):
    if check == 0:
        if xy[i][0] == 1:
            in_[xy[i][1] - 1] += 1
            check = 1
        else:
            if xy[i][1] == 1:
                in_[xy[i][1] - 1] += 1
                check = 1
        l[xy[i][0] - 1] -= 1
        l[xy[i][1] - 1] += 1
    else:
        l[xy[i][0] - 1] -= 1
        l[xy[i][1] - 1] += 1
        if l[xy[i][0] - 1] == 0 and in_[xy[i][0] - 1] != 0:
            in_[xy[i][0] - 1] = 0
            in_[xy[i][1] - 1] += 1
        elif l[xy[i][0] - 1] != 0 and in_[xy[i][0] - 1] != 0:
            in_[xy[i][1] - 1] += 1
ans = 0
for i in range(n):
    if in_[i] != 0:
        ans += 1
print(ans)

-in_ = [0] * n  # 入れられたことがある履歴。0番目だけは初期値1 +in_ = [0] * n -# print(in_) -        if xy[i][0] == 1:  # 箱1に入ってくる前に初めて箱1から赤いボールを移す場合 +        if xy[i][0] == 1: -        else:  # 箱１から赤いボールを移す前に白いボールが入ってくる場合 +        else: -        # print(l,in_) -        if l[xy[i][0] - 1] == 0 and in_[xy[i][0] - 1] != 0:  # 移した後、空になる場合 +        if l[xy[i][0] - 1] == 0 and in_[xy[i][0] - 1] != 0: -        elif l[xy[i][0] - 1] != 0 and in_[xy[i][0] - 1] != 0:  # 移した後、残っている場合 +        elif l[xy[i][0] - 1] != 0 and in_[xy[i][0] - 1] != 0: -        # print(l,in_) -# print(l,in_)