#!/usr/bin/env python3

(n, m), *q = [[*list(map(int, i.split()))] for i in open(0)]

b = [1] + [0] * (n - 1)

c = [1] * n

for x, y in q:

    c[x - 1] -= 1

    c[y - 1] += 1

    b[y - 1] |= b[x - 1]

    b[x - 1] *= c[x - 1] > 0

print((sum(b)))

(n, m), *q = [[*list(map(int, i.split()))] for i in open(0)]

b = [0] * (n + 1)

b[1] = 1

c = [1] * (n + 1)

for x, y in q:

    c[x] -= 1

    c[y] += 1

    b[y] |= b[x]

    b[x] *= c[x] > 0

print((sum(b)))

#!/usr/bin/env python3
(n, m), *q = [[*list(map(int, i.split()))] for i in open(0)]
b = [1] + [0] * (n - 1)
c = [1] * n
for x, y in q:
    c[x - 1] -= 1
    c[y - 1] += 1
    b[y - 1] |= b[x - 1]
    b[x - 1] *= c[x - 1] > 0
print((sum(b)))

(n, m), *q = [[*list(map(int, i.split()))] for i in open(0)]
b = [0] * (n + 1)
b[1] = 1
c = [1] * (n + 1)
for x, y in q:
    c[x] -= 1
    c[y] += 1
    b[y] |= b[x]
    b[x] *= c[x] > 0
print((sum(b)))

-#!/usr/bin/env python3 -b = [1] + [0] * (n - 1) -c = [1] * n +b = [0] * (n + 1) +b[1] = 1 +c = [1] * (n + 1) -    c[x - 1] -= 1 -    c[y - 1] += 1 -    b[y - 1] |= b[x - 1] -    b[x - 1] *= c[x - 1] > 0 +    c[x] -= 1 +    c[y] += 1 +    b[y] |= b[x] +    b[x] *= c[x] > 0