import sys

read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



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

m = list(map(int,read().split()))

XY = list(zip(m,m))



red = [0] + [1] + [0] * (N-1)

ball = [0] + [1] * N



for x,y in XY:

    if red[x]:

        red[y] = 1

    ball[x] -= 1; ball[y] += 1

    if not ball[x]:

        red[x] = 0



answer = sum(red)

print(answer)
import sys



read = sys.stdin.buffer.read

readline = sys.stdin.buffer.readline

readlines = sys.stdin.buffer.readlines



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

m = list(map(int, read().split()))



count = [1] * (N+1)

red = [0] * (N+1)

red[1] = True

for x, y in zip(m, m):

    count[x] -= 1

    count[y] += 1

    if red[x]:

        red[y] = 1

    if not count[x]:

        red[x] = 0



print((sum(red)))
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
XY = list(zip(m, m))
red = [0] + [1] + [0] * (N - 1)
ball = [0] + [1] * N
for x, y in XY:
    if red[x]:
        red[y] = 1
    ball[x] -= 1
    ball[y] += 1
    if not ball[x]:
        red[x] = 0
answer = sum(red)
print(answer)

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, M = list(map(int, readline().split()))
m = list(map(int, read().split()))
count = [1] * (N + 1)
red = [0] * (N + 1)
red[1] = True
for x, y in zip(m, m):
    count[x] -= 1
    count[y] += 1
    if red[x]:
        red[y] = 1
    if not count[x]:
        red[x] = 0
print((sum(red)))

-XY = list(zip(m, m)) -red = [0] + [1] + [0] * (N - 1) -ball = [0] + [1] * N -for x, y in XY: +count = [1] * (N + 1) +red = [0] * (N + 1) +red[1] = True +for x, y in zip(m, m): +    count[x] -= 1 +    count[y] += 1 -    ball[x] -= 1 -    ball[y] += 1 -    if not ball[x]: +    if not count[x]: -answer = sum(red) -print(answer) +print((sum(red)))