N, M = list(map(int, input().split()))

A = [1 for k in range(N)]

B = [0 for k in range(N)]



ans = 0

B[0] = 1

for k in range(M):

    x, y = list(map(int, input().split()))

    x -= 1

    y -= 1

    if B[x] == 1 and A[x] >= 2:

        A[x] -= 1

        A[y] += 1

        B[y] = 1

    elif B[x] == 1 and A[x] == 1:

        A[x] -= 1

        A[y] += 1

        B[x] = 0

        B[y] = 1

    else:

        A[x] -= 1

        A[y] += 1



print((B.count(1)))
N, M = list(map(int,input().split()))

B = [list(map(int,input().split())) for k in range(M)]

H = [1]*N

E = [0]*N

E[0] = 1

for e in B:

    x, y = e[0]-1, e[1]-1

    if E[x] == 1:

        if H[x] == 1:

            E[x] = 0

            E[y] = 1

        else:

            E[y] = 1

    H[x] -= 1

    H[y] += 1

print((E.count(1)))

N, M = list(map(int, input().split()))
A = [1 for k in range(N)]
B = [0 for k in range(N)]
ans = 0
B[0] = 1
for k in range(M):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    if B[x] == 1 and A[x] >= 2:
        A[x] -= 1
        A[y] += 1
        B[y] = 1
    elif B[x] == 1 and A[x] == 1:
        A[x] -= 1
        A[y] += 1
        B[x] = 0
        B[y] = 1
    else:
        A[x] -= 1
        A[y] += 1
print((B.count(1)))

N, M = list(map(int, input().split()))
B = [list(map(int, input().split())) for k in range(M)]
H = [1] * N
E = [0] * N
E[0] = 1
for e in B:
    x, y = e[0] - 1, e[1] - 1
    if E[x] == 1:
        if H[x] == 1:
            E[x] = 0
            E[y] = 1
        else:
            E[y] = 1
    H[x] -= 1
    H[y] += 1
print((E.count(1)))

-A = [1 for k in range(N)] -B = [0 for k in range(N)] -ans = 0 -B[0] = 1 -for k in range(M): -    x, y = list(map(int, input().split())) -    x -= 1 -    y -= 1 -    if B[x] == 1 and A[x] >= 2: -        A[x] -= 1 -        A[y] += 1 -        B[y] = 1 -    elif B[x] == 1 and A[x] == 1: -        A[x] -= 1 -        A[y] += 1 -        B[x] = 0 -        B[y] = 1 -    else: -        A[x] -= 1 -        A[y] += 1 -print((B.count(1))) +B = [list(map(int, input().split())) for k in range(M)] +H = [1] * N +E = [0] * N +E[0] = 1 +for e in B: +    x, y = e[0] - 1, e[1] - 1 +    if E[x] == 1: +        if H[x] == 1: +            E[x] = 0 +            E[y] = 1 +        else: +            E[y] = 1 +    H[x] -= 1 +    H[y] += 1 +print((E.count(1)))