(N, M), *AB = [list(map(int, s.split())) for s in open(0)]

cnt = [1] * N

possibly_red = [False] * N

possibly_red[0] = True

for a, b in AB:

    a -= 1

    b -= 1

    cnt[a] -= 1

    cnt[b] += 1

    if possibly_red[a]:

        possibly_red[b] = True

        if cnt[a] == 0:

            possibly_red[a] = False

print((sum(possibly_red)))

N, M, *xy = list(map(int, open(0).read().split()))

boxes = [{"count": 1, "red": False} for _ in range(N)]

boxes[0]["red"] = True



for x, y in zip(*[iter(xy)] * 2):

    x -= 1

    y -= 1

    if boxes[x]["red"]:

        boxes[y]["red"] = True

        if boxes[x]["count"] == 1:

            boxes[x]["red"] = False

    boxes[x]["count"] -= 1

    boxes[y]["count"] += 1

print((sum(b["red"] for b in boxes)))

(N, M), *AB = [list(map(int, s.split())) for s in open(0)]
cnt = [1] * N
possibly_red = [False] * N
possibly_red[0] = True
for a, b in AB:
    a -= 1
    b -= 1
    cnt[a] -= 1
    cnt[b] += 1
    if possibly_red[a]:
        possibly_red[b] = True
        if cnt[a] == 0:
            possibly_red[a] = False
print((sum(possibly_red)))

N, M, *xy = list(map(int, open(0).read().split()))
boxes = [{"count": 1, "red": False} for _ in range(N)]
boxes[0]["red"] = True
for x, y in zip(*[iter(xy)] * 2):
    x -= 1
    y -= 1
    if boxes[x]["red"]:
        boxes[y]["red"] = True
        if boxes[x]["count"] == 1:
            boxes[x]["red"] = False
    boxes[x]["count"] -= 1
    boxes[y]["count"] += 1
print((sum(b["red"] for b in boxes)))

-(N, M), *AB = [list(map(int, s.split())) for s in open(0)] -cnt = [1] * N -possibly_red = [False] * N -possibly_red[0] = True -for a, b in AB: -    a -= 1 -    b -= 1 -    cnt[a] -= 1 -    cnt[b] += 1 -    if possibly_red[a]: -        possibly_red[b] = True -        if cnt[a] == 0: -            possibly_red[a] = False -print((sum(possibly_red))) +N, M, *xy = list(map(int, open(0).read().split())) +boxes = [{"count": 1, "red": False} for _ in range(N)] +boxes[0]["red"] = True +for x, y in zip(*[iter(xy)] * 2): +    x -= 1 +    y -= 1 +    if boxes[x]["red"]: +        boxes[y]["red"] = True +        if boxes[x]["count"] == 1: +            boxes[x]["red"] = False +    boxes[x]["count"] -= 1 +    boxes[y]["count"] += 1 +print((sum(b["red"] for b in boxes)))