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, *xy = list(map(int, open(0).read().split()))

boxes = [1] * N

is_red = [0] * N

is_red[0] = 1



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

    x -= 1

    y -= 1

    boxes[x] -= 1

    boxes[y] += 1

    if is_red[x]:

        if boxes[x] == 0:

            is_red[x] = 0

        is_red[y] = 1

print((sum(is_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, *xy = list(map(int, open(0).read().split()))
boxes = [1] * N
is_red = [0] * N
is_red[0] = 1
for x, y in zip(*[iter(xy)] * 2):
    x -= 1
    y -= 1
    boxes[x] -= 1
    boxes[y] += 1
    if is_red[x]:
        if boxes[x] == 0:
            is_red[x] = 0
        is_red[y] = 1
print((sum(is_red)))

-boxes = [{"count": 1, "red": False} for _ in range(N)] -boxes[0]["red"] = True +boxes = [1] * N +is_red = [0] * N +is_red[0] = 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))) +    boxes[x] -= 1 +    boxes[y] += 1 +    if is_red[x]: +        if boxes[x] == 0: +            is_red[x] = 0 +        is_red[y] = 1 +print((sum(is_red)))