# coding: utf-8

# Your code here!s = input()

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

x = []

y = []

for i in range(m):

    xi, yi = list(map(int, input().split()))

    x.append(xi)

    y.append(yi)

boxes = [False]*n

boxes[0] = True

boxescnt = [1]*n

for i in range(m):

    if boxes[x[i]-1] == True:

        if boxescnt[x[i]-1] == 1:

            boxes[x[i]-1] = False

        boxes[y[i]-1] = True

    boxescnt[x[i]-1] -= 1

    boxescnt[y[i]-1] += 1

print((sum(boxes)))

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

x = []

y = []

for i in range(m):

    xi, yi = list(map(int, input().split()))

    x.append(xi)

    y.append(yi)

num = [1]*n

able = [False]*n

able[0] = True

for i in range(m):

    if able[x[i]-1] == True:

        able[y[i]-1] = True

    num[x[i]-1] -= 1

    num[y[i]-1] += 1

    if num[x[i]-1] == 0:

        able[x[i]-1] = False

print((sum(able)))
# coding: utf-8
# Your code here!s = input()
n, m = list(map(int, input().split()))
x = []
y = []
for i in range(m):
    xi, yi = list(map(int, input().split()))
    x.append(xi)
    y.append(yi)
boxes = [False] * n
boxes[0] = True
boxescnt = [1] * n
for i in range(m):
    if boxes[x[i] - 1] == True:
        if boxescnt[x[i] - 1] == 1:
            boxes[x[i] - 1] = False
        boxes[y[i] - 1] = True
    boxescnt[x[i] - 1] -= 1
    boxescnt[y[i] - 1] += 1
print((sum(boxes)))

n, m = list(map(int, input().split()))
x = []
y = []
for i in range(m):
    xi, yi = list(map(int, input().split()))
    x.append(xi)
    y.append(yi)
num = [1] * n
able = [False] * n
able[0] = True
for i in range(m):
    if able[x[i] - 1] == True:
        able[y[i] - 1] = True
    num[x[i] - 1] -= 1
    num[y[i] - 1] += 1
    if num[x[i] - 1] == 0:
        able[x[i] - 1] = False
print((sum(able)))

-# coding: utf-8 -# Your code here!s = input() -boxes = [False] * n -boxes[0] = True -boxescnt = [1] * n +num = [1] * n +able = [False] * n +able[0] = True -    if boxes[x[i] - 1] == True: -        if boxescnt[x[i] - 1] == 1: -            boxes[x[i] - 1] = False -        boxes[y[i] - 1] = True -    boxescnt[x[i] - 1] -= 1 -    boxescnt[y[i] - 1] += 1 -print((sum(boxes))) +    if able[x[i] - 1] == True: +        able[y[i] - 1] = True +    num[x[i] - 1] -= 1 +    num[y[i] - 1] += 1 +    if num[x[i] - 1] == 0: +        able[x[i] - 1] = False +print((sum(able)))