# AGC002B - Box and Ball

import sys

input = sys.stdin.readline



def main():

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

    X = tuple(tuple(map(int, input().split())) for _ in range(M))

    R = [0] * (N + 1)  # red ball may be in box i

    R[1] = 1

    C = [1] * (N + 1)  # number of balls in box i (count)

    for x, y in X:

        if R[x]:

            R[y] = 1

        C[x] -= 1

        C[y] += 1

        if C[x] == 0:

            R[x] = 0

    ans = sum(R[1:])

    print(ans)





if __name__ == "__main__":

    main()
# AGC002B - Box and Ball

def main():

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

    R = [0] * (N + 1)  # red ball may be in box i

    R[1] = 1

    C = [1] * (N + 1)  # number of balls in box i (count)

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

        R[y] = 1 if R[x] or R[y] else 0  # red ball may move from x to y

        C[x] -= 1

        C[y] += 1

        R[x] = 0 if C[x] == 0 else R[x]  # no more ball in x

    ans = sum(R[1:])

    print(ans)





if __name__ == "__main__":

    main()
# AGC002B - Box and Ball
import sys

input = sys.stdin.readline


def main():
    N, M = tuple(map(int, input().split()))
    X = tuple(tuple(map(int, input().split())) for _ in range(M))
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in X:
        if R[x]:
            R[y] = 1
        C[x] -= 1
        C[y] += 1
        if C[x] == 0:
            R[x] = 0
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

# AGC002B - Box and Ball
def main():
    N, M, *XY = list(map(int, open(0).read().split()))
    R = [0] * (N + 1)  # red ball may be in box i
    R[1] = 1
    C = [1] * (N + 1)  # number of balls in box i (count)
    for x, y in zip(*[iter(XY)] * 2):
        R[y] = 1 if R[x] or R[y] else 0  # red ball may move from x to y
        C[x] -= 1
        C[y] += 1
        R[x] = 0 if C[x] == 0 else R[x]  # no more ball in x
    ans = sum(R[1:])
    print(ans)


if __name__ == "__main__":
    main()

-import sys - -input = sys.stdin.readline - - -    N, M = tuple(map(int, input().split())) -    X = tuple(tuple(map(int, input().split())) for _ in range(M)) +    N, M, *XY = list(map(int, open(0).read().split())) -    for x, y in X: -        if R[x]: -            R[y] = 1 +    for x, y in zip(*[iter(XY)] * 2): +        R[y] = 1 if R[x] or R[y] else 0  # red ball may move from x to y -        if C[x] == 0: -            R[x] = 0 +        R[x] = 0 if C[x] == 0 else R[x]  # no more ball in x