import sys



sys.setrecursionlimit(10 ** 5 + 10)





def input(): return sys.stdin.readline().strip()





def resolve():

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

    quantity = [1] * N

    red = [True] + [False] * (N - 1)



    for i in range(M):

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

        quantity[x - 1] -= 1

        quantity[y - 1] += 1

        if red[x - 1] == True:

            red[y - 1] = True



        if quantity[x - 1] == 0:

            red[x - 1] = False

    print((red.count(True)))





resolve()
import sys

sys.setrecursionlimit(10 ** 5 + 10)

def input(): return sys.stdin.readline().strip()



def resolve():



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

    X, Y = [0] * M, [0] * M

    for i in range(M):

        X[i], Y[i] = list(map(int, input().split()))



    red=[True]+[False]*(N-1)

    cnt=[1]*N



    for i in range(M):

        cnt[X[i]-1]-=1

        cnt[Y[i]-1]+=1

        if red[X[i]-1]:

            red[Y[i]-1]=True

        if cnt[X[i]-1]==0:

            red[X[i] - 1]=False



    print((red.count(True)))





resolve()
import sys

sys.setrecursionlimit(10**5 + 10)


def input():
    return sys.stdin.readline().strip()


def resolve():
    N, M = list(map(int, input().split()))
    quantity = [1] * N
    red = [True] + [False] * (N - 1)
    for i in range(M):
        x, y = list(map(int, input().split()))
        quantity[x - 1] -= 1
        quantity[y - 1] += 1
        if red[x - 1] == True:
            red[y - 1] = True
        if quantity[x - 1] == 0:
            red[x - 1] = False
    print((red.count(True)))


resolve()

import sys

sys.setrecursionlimit(10**5 + 10)


def input():
    return sys.stdin.readline().strip()


def resolve():
    N, M = list(map(int, input().split()))
    X, Y = [0] * M, [0] * M
    for i in range(M):
        X[i], Y[i] = list(map(int, input().split()))
    red = [True] + [False] * (N - 1)
    cnt = [1] * N
    for i in range(M):
        cnt[X[i] - 1] -= 1
        cnt[Y[i] - 1] += 1
        if red[X[i] - 1]:
            red[Y[i] - 1] = True
        if cnt[X[i] - 1] == 0:
            red[X[i] - 1] = False
    print((red.count(True)))


resolve()

-    quantity = [1] * N +    X, Y = [0] * M, [0] * M +    for i in range(M): +        X[i], Y[i] = list(map(int, input().split())) +    cnt = [1] * N -        x, y = list(map(int, input().split())) -        quantity[x - 1] -= 1 -        quantity[y - 1] += 1 -        if red[x - 1] == True: -            red[y - 1] = True -        if quantity[x - 1] == 0: -            red[x - 1] = False +        cnt[X[i] - 1] -= 1 +        cnt[Y[i] - 1] += 1 +        if red[X[i] - 1]: +            red[Y[i] - 1] = True +        if cnt[X[i] - 1] == 0: +            red[X[i] - 1] = False