from sys import stdin

def main():

    #入力

    readline=stdin.readline

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

    x=[0]*M

    y=[0]*M

    for i in range(M):

        a,b=list(map(int,readline().split()))

        x[i]=a

        y[i]=b



    li=[[1,0] for _ in range(N+1)]

    li[1][1]=1

    for i in range(M):

        if li[x[i]][0]>=2 and li[x[i]][1]==1:

            li[y[i]][0]+=1

            li[y[i]][1]=1



            li[x[i]][0]-=1



        elif li[x[i]][0]==1 and li[x[i]][1]==1:

            li[y[i]][0]+=1

            li[y[i]][1]=1



            li[x[i]][0]-=1

            li[x[i]][1]=0



        else:

            li[y[i]][0]+=1



            li[x[i]][0]-=1

            

    count=0

    for i in range(1,N+1):

        if li[i][1]==1: count+=1

    print(count)

if __name__=="__main__":

    main()
from sys import stdin

def main():

    #入力

    readline=stdin.readline

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

    x=[0]*M

    y=[0]*M

    for i in range(M):

        x[i],y[i]=list(map(int,readline().split()))



    box=[1]*(N+1)

    flags=[False]*(N+1)

    flags[1]=True



    for i in range(M):

        out=x[i]

        inn=y[i]

        if flags[out]==True and box[out]==1:

            flags[out]=False

            flags[inn]=True

        elif flags[out]==True:

            flags[inn]=True

        box[out]-=1

        box[inn]+=1



    res=0

    for i in range(N+1):

        if flags[i]==True:

            res+=1

    print(res)

        

if __name__=="__main__":

    main()
from sys import stdin


def main():
    # 入力
    readline = stdin.readline
    N, M = list(map(int, readline().split()))
    x = [0] * M
    y = [0] * M
    for i in range(M):
        a, b = list(map(int, readline().split()))
        x[i] = a
        y[i] = b
    li = [[1, 0] for _ in range(N + 1)]
    li[1][1] = 1
    for i in range(M):
        if li[x[i]][0] >= 2 and li[x[i]][1] == 1:
            li[y[i]][0] += 1
            li[y[i]][1] = 1
            li[x[i]][0] -= 1
        elif li[x[i]][0] == 1 and li[x[i]][1] == 1:
            li[y[i]][0] += 1
            li[y[i]][1] = 1
            li[x[i]][0] -= 1
            li[x[i]][1] = 0
        else:
            li[y[i]][0] += 1
            li[x[i]][0] -= 1
    count = 0
    for i in range(1, N + 1):
        if li[i][1] == 1:
            count += 1
    print(count)


if __name__ == "__main__":
    main()

from sys import stdin


def main():
    # 入力
    readline = stdin.readline
    N, M = list(map(int, readline().split()))
    x = [0] * M
    y = [0] * M
    for i in range(M):
        x[i], y[i] = list(map(int, readline().split()))
    box = [1] * (N + 1)
    flags = [False] * (N + 1)
    flags[1] = True
    for i in range(M):
        out = x[i]
        inn = y[i]
        if flags[out] == True and box[out] == 1:
            flags[out] = False
            flags[inn] = True
        elif flags[out] == True:
            flags[inn] = True
        box[out] -= 1
        box[inn] += 1
    res = 0
    for i in range(N + 1):
        if flags[i] == True:
            res += 1
    print(res)


if __name__ == "__main__":
    main()

-        a, b = list(map(int, readline().split())) -        x[i] = a -        y[i] = b -    li = [[1, 0] for _ in range(N + 1)] -    li[1][1] = 1 +        x[i], y[i] = list(map(int, readline().split())) +    box = [1] * (N + 1) +    flags = [False] * (N + 1) +    flags[1] = True -        if li[x[i]][0] >= 2 and li[x[i]][1] == 1: -            li[y[i]][0] += 1 -            li[y[i]][1] = 1 -            li[x[i]][0] -= 1 -        elif li[x[i]][0] == 1 and li[x[i]][1] == 1: -            li[y[i]][0] += 1 -            li[y[i]][1] = 1 -            li[x[i]][0] -= 1 -            li[x[i]][1] = 0 -        else: -            li[y[i]][0] += 1 -            li[x[i]][0] -= 1 -    count = 0 -    for i in range(1, N + 1): -        if li[i][1] == 1: -            count += 1 -    print(count) +        out = x[i] +        inn = y[i] +        if flags[out] == True and box[out] == 1: +            flags[out] = False +            flags[inn] = True +        elif flags[out] == True: +            flags[inn] = True +        box[out] -= 1 +        box[inn] += 1 +    res = 0 +    for i in range(N + 1): +        if flags[i] == True: +            res += 1 +    print(res)