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



B = [1] * n

R = [0] * n

R[0] = 1

for _ in range(m):

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

    x -= 1; y -= 1



    if B[x] == 1 and R[x] == 1:

        R[x] =  0; R[y] =  1

    elif B[x] > 1 and R[x] == 1:

        R[y] =  1

    B[x] -= 1; B[y] += 1



print((len([i for i in R if i==1])))
n, m = list(map(int, input().split()))



red = [False] * n

ball = [1] * n



red[0] = True

for _ in range(m):

    x, y = [int(x) - 1 for x in input().split()]

    if red[x]:

        red[y] = True

        if ball[x] == 1:

            red[x] = False

    ball[y] += 1

    ball[x] -= 1

print((len(list([x for x in red if x]))))

n, m = list(map(int, input().split()))
B = [1] * n
R = [0] * n
R[0] = 1
for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    if B[x] == 1 and R[x] == 1:
        R[x] = 0
        R[y] = 1
    elif B[x] > 1 and R[x] == 1:
        R[y] = 1
    B[x] -= 1
    B[y] += 1
print((len([i for i in R if i == 1])))

n, m = list(map(int, input().split()))
red = [False] * n
ball = [1] * n
red[0] = True
for _ in range(m):
    x, y = [int(x) - 1 for x in input().split()]
    if red[x]:
        red[y] = True
        if ball[x] == 1:
            red[x] = False
    ball[y] += 1
    ball[x] -= 1
print((len(list([x for x in red if x]))))

-B = [1] * n -R = [0] * n -R[0] = 1 +red = [False] * n +ball = [1] * n +red[0] = True -    x, y = list(map(int, input().split())) -    x -= 1 -    y -= 1 -    if B[x] == 1 and R[x] == 1: -        R[x] = 0 -        R[y] = 1 -    elif B[x] > 1 and R[x] == 1: -        R[y] = 1 -    B[x] -= 1 -    B[y] += 1 -print((len([i for i in R if i == 1]))) +    x, y = [int(x) - 1 for x in input().split()] +    if red[x]: +        red[y] = True +        if ball[x] == 1: +            red[x] = False +    ball[y] += 1 +    ball[x] -= 1 +print((len(list([x for x in red if x]))))