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

boxes = [1] * N

ans = {1}

for i in range(M):

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

    boxes[x - 1] -= 1

    boxes[y - 1] += 1

    if x in ans:

        if boxes[x - 1] == 0:

            ans.remove(x)

        ans.add(y)

print((len(ans)))

def int_(num_str):

    return int(num_str) - 1



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

balls = [1] * N

red = {0}

for i in range(M):

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

    if x in red:

        if balls[x] == 1:

            red.remove(x)

            red.add(y)

        else:

            red.add(y)

    balls[x] -= 1

    balls[y] += 1

print((len(red)))
N, M = list(map(int, input().split()))
boxes = [1] * N
ans = {1}
for i in range(M):
    x, y = list(map(int, input().split()))
    boxes[x - 1] -= 1
    boxes[y - 1] += 1
    if x in ans:
        if boxes[x - 1] == 0:
            ans.remove(x)
        ans.add(y)
print((len(ans)))

def int_(num_str):
    return int(num_str) - 1


N, M = list(map(int, input().split()))
balls = [1] * N
red = {0}
for i in range(M):
    x, y = list(map(int_, input().split()))
    if x in red:
        if balls[x] == 1:
            red.remove(x)
            red.add(y)
        else:
            red.add(y)
    balls[x] -= 1
    balls[y] += 1
print((len(red)))

+def int_(num_str): +    return int(num_str) - 1 + + -boxes = [1] * N -ans = {1} +balls = [1] * N +red = {0} -    x, y = list(map(int, input().split())) -    boxes[x - 1] -= 1 -    boxes[y - 1] += 1 -    if x in ans: -        if boxes[x - 1] == 0: -            ans.remove(x) -        ans.add(y) -print((len(ans))) +    x, y = list(map(int_, input().split())) +    if x in red: +        if balls[x] == 1: +            red.remove(x) +            red.add(y) +        else: +            red.add(y) +    balls[x] -= 1 +    balls[y] += 1 +print((len(red)))