i=lambda:list(map(int,input().split()));n,m=i();l=[0,1]+[0]*n;c=[0]+[1]*n

for _ in[0]*m:x,y=i();l[y]|=l[x];c[y]+=1;c[x]-=1;l[x]=c[x]and l[x]

print((sum(c[i]and l[i]for i in range(n+1))))
i=lambda:list(map(int,input().split()));n,m=i();a=[0]+[1]*n;b=[0,1]+[0]*n

for _ in[0]*m:x,y=i();a[x]-=1;a[y]+=1;b[y]|=b[x];b[x]&=a[x]>0

print((sum(b)))
i = lambda: list(map(int, input().split()))
n, m = i()
l = [0, 1] + [0] * n
c = [0] + [1] * n
for _ in [0] * m:
    x, y = i()
    l[y] |= l[x]
    c[y] += 1
    c[x] -= 1
    l[x] = c[x] and l[x]
print((sum(c[i] and l[i] for i in range(n + 1))))

i = lambda: list(map(int, input().split()))
n, m = i()
a = [0] + [1] * n
b = [0, 1] + [0] * n
for _ in [0] * m:
    x, y = i()
    a[x] -= 1
    a[y] += 1
    b[y] |= b[x]
    b[x] &= a[x] > 0
print((sum(b)))

-l = [0, 1] + [0] * n -c = [0] + [1] * n +a = [0] + [1] * n +b = [0, 1] + [0] * n -    l[y] |= l[x] -    c[y] += 1 -    c[x] -= 1 -    l[x] = c[x] and l[x] -print((sum(c[i] and l[i] for i in range(n + 1)))) +    a[x] -= 1 +    a[y] += 1 +    b[y] |= b[x] +    b[x] &= a[x] > 0 +print((sum(b)))