# AGC002B - Box and Ball

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

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 = 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
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()

+import sys + +input = sys.stdin.readline + +