n, m = (int(x) for x in input().split())

ab = []

for _ in range(m):

    a, b = (int(x) for x in input().split())

    ab.append([a-1, b-1])



box = [1]*n



red = [0]*n



red[0] = 1



for x,y in ab:

    if 0 < red[x]:

        red[y] = 1

    box[x] -= 1

    box[y] += 1



    if box[x] == 0:

        red[x] = 0

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



XY = [list(map(int,input().split())) for _ in range(M)]



ball_count = [1]*N



red_ball_cand = [0]*N

red_ball_cand[0] = 1



for i in range(M):

    x,y = XY[i]

    x,y = x-1,y-1

    if 0 < red_ball_cand[x]:

        red_ball_cand[y] = 1

        

    ball_count[x] -= 1

    ball_count[y] += 1

    

    if ball_count[x] == 0:

        red_ball_cand[x] = 0

print((sum(red_ball_cand)))
n, m = (int(x) for x in input().split())
ab = []
for _ in range(m):
    a, b = (int(x) for x in input().split())
    ab.append([a - 1, b - 1])
box = [1] * n
red = [0] * n
red[0] = 1
for x, y in ab:
    if 0 < red[x]:
        red[y] = 1
    box[x] -= 1
    box[y] += 1
    if box[x] == 0:
        red[x] = 0
print((sum(red)))

N, M = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(M)]
ball_count = [1] * N
red_ball_cand = [0] * N
red_ball_cand[0] = 1
for i in range(M):
    x, y = XY[i]
    x, y = x - 1, y - 1
    if 0 < red_ball_cand[x]:
        red_ball_cand[y] = 1
    ball_count[x] -= 1
    ball_count[y] += 1
    if ball_count[x] == 0:
        red_ball_cand[x] = 0
print((sum(red_ball_cand)))

-n, m = (int(x) for x in input().split()) -ab = [] -for _ in range(m): -    a, b = (int(x) for x in input().split()) -    ab.append([a - 1, b - 1]) -box = [1] * n -red = [0] * n -red[0] = 1 -for x, y in ab: -    if 0 < red[x]: -        red[y] = 1 -    box[x] -= 1 -    box[y] += 1 -    if box[x] == 0: -        red[x] = 0 -print((sum(red))) +N, M = list(map(int, input().split())) +XY = [list(map(int, input().split())) for _ in range(M)] +ball_count = [1] * N +red_ball_cand = [0] * N +red_ball_cand[0] = 1 +for i in range(M): +    x, y = XY[i] +    x, y = x - 1, y - 1 +    if 0 < red_ball_cand[x]: +        red_ball_cand[y] = 1 +    ball_count[x] -= 1 +    ball_count[y] += 1 +    if ball_count[x] == 0: +        red_ball_cand[x] = 0 +print((sum(red_ball_cand)))