# coding:utf-8



INF = float('inf')





def inpl(): return list(map(int, input().split()))





N, M = inpl()

# move = [inpl() for _ in range(M)]



ans = [0 for _ in range(N)]

ans[0] = 1

box = [1 for _ in range(N)]

# print(ans, box)

for i in range(M):

    # x, y = move[i]

    x, y = inpl()

    box[x - 1] -= 1

    box[y - 1] += 1

    if ans[x - 1]:

        ans[y - 1] = 1

        if box[x - 1] == 0:

            ans[x - 1] = 0

    # print(ans, box)





print((sum(ans)))
# coding:utf-8



import sys



INF = float('inf')

MOD = 10 ** 9 + 7



def LI(): return [int(x) for x in sys.stdin.readline().split()]

def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF(): return [float(x) for x in sys.stdin.readline().split()]

def LS(): return sys.stdin.readline().split()

def II(): return int(sys.stdin.readline())

def SI(): return eval(input())





def main():

    n, m = LI()



    B = [1] * n

    R = [0] * n

    R[0] = 1



    for _ in range(m):

        x, y = LI_()



        B[x] -= 1

        B[y] += 1



        # 赤いボールが移動したかも？

        if R[x]:

            R[y] = 1



        # 箱が空なので赤いボールは絶対入ってない！

        if not B[x]:

            R[x] = 0



    return sum(R)





print((main()))

# coding:utf-8
INF = float("inf")


def inpl():
    return list(map(int, input().split()))


N, M = inpl()
# move = [inpl() for _ in range(M)]
ans = [0 for _ in range(N)]
ans[0] = 1
box = [1 for _ in range(N)]
# print(ans, box)
for i in range(M):
    # x, y = move[i]
    x, y = inpl()
    box[x - 1] -= 1
    box[y - 1] += 1
    if ans[x - 1]:
        ans[y - 1] = 1
        if box[x - 1] == 0:
            ans[x - 1] = 0
    # print(ans, box)
print((sum(ans)))

# coding:utf-8
import sys

INF = float("inf")
MOD = 10**9 + 7


def LI():
    return [int(x) for x in sys.stdin.readline().split()]


def LI_():
    return [int(x) - 1 for x in sys.stdin.readline().split()]


def LF():
    return [float(x) for x in sys.stdin.readline().split()]


def LS():
    return sys.stdin.readline().split()


def II():
    return int(sys.stdin.readline())


def SI():
    return eval(input())


def main():
    n, m = LI()
    B = [1] * n
    R = [0] * n
    R[0] = 1
    for _ in range(m):
        x, y = LI_()
        B[x] -= 1
        B[y] += 1
        # 赤いボールが移動したかも？
        if R[x]:
            R[y] = 1
        # 箱が空なので赤いボールは絶対入ってない！
        if not B[x]:
            R[x] = 0
    return sum(R)


print((main()))

+import sys + +MOD = 10**9 + 7 -def inpl(): -    return list(map(int, input().split())) +def LI(): +    return [int(x) for x in sys.stdin.readline().split()] -N, M = inpl() -# move = [inpl() for _ in range(M)] -ans = [0 for _ in range(N)] -ans[0] = 1 -box = [1 for _ in range(N)] -# print(ans, box) -for i in range(M): -    # x, y = move[i] -    x, y = inpl() -    box[x - 1] -= 1 -    box[y - 1] += 1 -    if ans[x - 1]: -        ans[y - 1] = 1 -        if box[x - 1] == 0: -            ans[x - 1] = 0 -    # print(ans, box) -print((sum(ans))) +def LI_(): +    return [int(x) - 1 for x in sys.stdin.readline().split()] + + +def LF(): +    return [float(x) for x in sys.stdin.readline().split()] + + +def LS(): +    return sys.stdin.readline().split() + + +def II(): +    return int(sys.stdin.readline()) + + +def SI(): +    return eval(input()) + + +def main(): +    n, m = LI() +    B = [1] * n +    R = [0] * n +    R[0] = 1 +    for _ in range(m): +        x, y = LI_() +        B[x] -= 1 +        B[y] += 1 +        # 赤いボールが移動したかも？ +        if R[x]: +            R[y] = 1 +        # 箱が空なので赤いボールは絶対入ってない！ +        if not B[x]: +            R[x] = 0 +    return sum(R) + + +print((main()))