n, m = list(map(int, input().split()))

white = [1]*n

white[0] = 0

red = [0] * n

red[0] = 1



for _ in range(m):

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

    x -= 1

    y -= 1



    if red[x] > 0:

        red[y] += 1

    else:

        white[y] += 1



    if white[x] > 0:

        white[x] -= 1

    else:

        red[x] -= 1





ans = n-red.count(0)

print(ans)

import sys

input = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 7)



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

red = [0] * (N + 1)

white = [1] * (N + 1)

red[1] = 1

white[1] = 0



for _ in range(M):

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

    if red[x]:

        red[y] += 1

    else:

        white[y] += 1

    if white[x]:

        white[x] -= 1

    else:

        red[x] -= 1



print((N-red[1:].count(0)))
n, m = list(map(int, input().split()))
white = [1] * n
white[0] = 0
red = [0] * n
red[0] = 1
for _ in range(m):
    x, y = list(map(int, input().split()))
    x -= 1
    y -= 1
    if red[x] > 0:
        red[y] += 1
    else:
        white[y] += 1
    if white[x] > 0:
        white[x] -= 1
    else:
        red[x] -= 1
ans = n - red.count(0)
print(ans)

import sys

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
N, M = list(map(int, input().split()))
red = [0] * (N + 1)
white = [1] * (N + 1)
red[1] = 1
white[1] = 0
for _ in range(M):
    x, y = list(map(int, input().split()))
    if red[x]:
        red[y] += 1
    else:
        white[y] += 1
    if white[x]:
        white[x] -= 1
    else:
        red[x] -= 1
print((N - red[1:].count(0)))

-n, m = list(map(int, input().split())) -white = [1] * n -white[0] = 0 -red = [0] * n -red[0] = 1 -for _ in range(m): +import sys + +input = sys.stdin.buffer.readline +sys.setrecursionlimit(10**7) +N, M = list(map(int, input().split())) +red = [0] * (N + 1) +white = [1] * (N + 1) +red[1] = 1 +white[1] = 0 +for _ in range(M): -    x -= 1 -    y -= 1 -    if red[x] > 0: +    if red[x]: -    if white[x] > 0: +    if white[x]: -ans = n - red.count(0) -print(ans) +print((N - red[1:].count(0)))