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

C = [1]*n

X = [0]*n

X[0] = 1

for i in range(m):

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

    x, y = x-1, y-1

    if X[x] == 1:

        C[x] -= 1

        C[y] += 1

        X[y] = 1

        if C[x] == 0:

            X[x] = 0

    else:

        C[x] -= 1

        C[y] += 1

#print(C)

#print(X)

print((sum(X)))

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



X = [0]*n

C = [1]*n

X[0] = 1



for i in range(m):

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

    x, y = x-1, y-1

    if X[x] == 1:

        X[y] = 1

        if C[x] == 1:

            X[x] = 0

        C[x] -= 1

        C[y] += 1

    else:

        C[x] -= 1

        C[y] += 1



ans = sum(X)

print(ans)

n, m = list(map(int, input().split()))
C = [1] * n
X = [0] * n
X[0] = 1
for i in range(m):
    x, y = list(map(int, input().split()))
    x, y = x - 1, y - 1
    if X[x] == 1:
        C[x] -= 1
        C[y] += 1
        X[y] = 1
        if C[x] == 0:
            X[x] = 0
    else:
        C[x] -= 1
        C[y] += 1
# print(C)
# print(X)
print((sum(X)))

n, m = list(map(int, input().split()))
X = [0] * n
C = [1] * n
X[0] = 1
for i in range(m):
    x, y = list(map(int, input().split()))
    x, y = x - 1, y - 1
    if X[x] == 1:
        X[y] = 1
        if C[x] == 1:
            X[x] = 0
        C[x] -= 1
        C[y] += 1
    else:
        C[x] -= 1
        C[y] += 1
ans = sum(X)
print(ans)

+X = [0] * n -X = [0] * n +        X[y] = 1 +        if C[x] == 1: +            X[x] = 0 -        X[y] = 1 -        if C[x] == 0: -            X[x] = 0 -# print(C) -# print(X) -print((sum(X))) +ans = sum(X) +print(ans)