We have N boxes, numbered 1 through N. At first, box 1 contains one red ball, and each of the other boxes contains one white ball.

Snuke will perform the following M operations, one by one. In the i-th operation, he randomly picks one ball from box x_i, then he puts it into box y_i.

Find the number of boxes that may contain the red ball after all operations are performed.

Constraints

* 2≤N≤10^5
* 1≤M≤10^5
* 1≤x_i,y_i≤N
* x_i≠y_i
* Just before the i-th operation is performed, box x_i contains at least 1 ball.

Input

The input is given from Standard Input in the following format:


N M
x_1 y_1
:
x_M y_M


Output

Print the number of boxes that may contain the red ball after all operations are performed.

Examples

Input

3 2
1 2
2 3


Output

2


Input

3 3
1 2
2 3
2 3


Output

1


Input

4 4
1 2
2 3
4 1
3 4


Output

3

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
(n, m) = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(m)]
red = [1] + [0] * (n - 1)
ball = [1] * n
for i in xy:
	(x, y) = (i[0] - 1, i[1] - 1)
	if red[x] == 1:
		red[y] = 1
	ball[x] -= 1
	ball[y] += 1
	if ball[x] == 0:
		red[x] = 0
print(red.count(1))


from collections import defaultdict
(n, m) = map(int, input().split())
v = [0] * n
v[0] = 1
ans = [1] * n
fi = 1
for i in range(m):
	(a, b) = map(int, input().split())
	ans[a - 1] -= 1
	ans[b - 1] += 1
	if v[a - 1]:
		v[b - 1] = 1
		fi += 1
	if ans[a - 1] == 0:
		v[a - 1] = 0
		fi -= 1
print(sum(v))


(n, m) = map(int, input().split())
check = [False] * n
check[0] = True
ball = [1] * n
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if check[x]:
		check[y] = True
	ball[y] += 1
	ball[x] -= 1
	if ball[x] == 0:
		check[x] = False
print(check.count(True))


(n, m) = map(int, input().split())
dp = [False] * n
dp2 = [1] * n
dp[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	dp2[y] += 1
	if dp[x] == True:
		dp[y] = True
	dp2[x] -= 1
	if dp2[x] == 0:
		dp[x] = False
ans = 0
for i in range(n):
	if dp[i] == True:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
red = [False for _ in range(n)]
nb = [1 for _ in range(n)]
red[0] = True
for _ in range(m):
	(x, y) = map(int, input().split())
	if red[x - 1]:
		red[y - 1] = True
	nb[x - 1] -= 1
	nb[y - 1] += 1
	if nb[x - 1] == 0:
		red[x - 1] = False
print(sum((1 for r in red if r)))


(n, m) = map(int, input().split())
ball = [1] * n
p = set()
p.add(1)
for i in range(m):
	(x, y) = map(int, input().split())
	ball[x - 1] -= 1
	ball[y - 1] += 1
	if x in p:
		p.add(y)
	if x in p:
		if ball[x - 1] == 0:
			p.remove(x)
print(len(p))


(n, m) = map(int, input().split())
l = [1] + [0] * (n + 1)
a = [1] * n
for i in range(m):
	(x, y) = map(int, input().split())
	if l[x - 1]:
		l[y - 1] = 1
	a[x - 1] -= 1
	a[y - 1] += 1
	if not a[x - 1]:
		l[x - 1] = 0
print(l.count(1))


(N, M) = map(int, input().split())
box = [1] * N
cld = [False] * N
cld[0] = True
for i in range(M):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if cld[x]:
		if box[x] == 1:
			cld[x] = False
		cld[y] = True
	box[x] -= 1
	box[y] += 1
print(sum(cld))


(N, M) = map(int, input().split())
dp = [1] * N
red = [False] * N
red[0] = True
for i in range(M):
	(xi, yi) = map(int, input().split())
	xi -= 1
	yi -= 1
	dp[yi] += 1
	red[yi] = red[yi] or red[xi]
	dp[xi] -= 1
	if dp[xi] == 0:
		red[xi] = False
ans = sum(red)
print(ans)


(n, m) = map(int, input().split())
stack = [1] * n
p = [False] * n
p[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	stack[x - 1] -= 1
	stack[y - 1] += 1
	p[y - 1] = p[x - 1] or p[y - 1]
	if stack[x - 1] == 0:
		p[x - 1] = False
ans = 0
for i in p:
	if i:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
ans = set()
ans.add(0)
l = [1 for i in range(n)]
for i in range(m):
	(x, y) = [int(j) - 1 for j in input().split()]
	l[x] -= 1
	l[y] += 1
	if x in ans:
		ans.add(y)
		if l[x] == 0:
			ans.remove(x)
print(len(ans))


(n, m) = map(int, input().split())
num = [1] * n
red = [True] + [False] * (n - 1)
for _ in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if red[x]:
		red[y] = True
	num[x] -= 1
	num[y] += 1
	if not num[x]:
		red[x] = False
print(sum(red))


(N, M) = map(int, input().split())
B = [1] * N
R = [0] * N
R[0] = 1
for i in range(M):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if R[x] == 1:
		R[y] = 1
	B[x] -= 1
	B[y] += 1
	if B[x] == 0:
		R[x] = 0
print(sum(R))


(n, m) = map(int, input().split())
p = [1] * n
q = [0] * n
q[0] += 1
for i in range(m):
	(x, y) = map(int, input().split())
	p[y - 1] += 1
	p[x - 1] -= 1
	if q[x - 1] == 1:
		q[y - 1] = 1
		if p[x - 1] == 0:
			q[x - 1] = 0
print(sum(q))


(n, m) = map(int, input().split())
cnt = [1] * (n + 1)
in_r = [0] * (n + 1)
in_r[1] = 1
for _ in range(m):
	(x, y) = map(int, input().split())
	cnt[x] -= 1
	cnt[y] += 1
	if in_r[x] == 1:
		in_r[x] = min(cnt[x], 1)
		in_r[y] = 1
ans = sum(in_r)
print(ans)


(n, m) = map(int, input().split())
box = [1] * n
boxz = [1] + [0] * (n - 1)
for i in range(m):
	(x, y) = map(int, input().split())
	box[y - 1] += 1
	box[x - 1] -= 1
	if boxz[x - 1] == 1:
		boxz[y - 1] = 1
		if box[x - 1] == 0:
			boxz[x - 1] = 0
print(sum(boxz))


(N, M) = map(int, input().split())
(R, A) = ([0] * N, [1] * N)
R[0] = 1
for i in range(M):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	if A[x] > 1 and R[x] == 1:
		R[y] = 1
	elif A[x] == R[x] == 1:
		R[x] = 0
		R[y] = 1
	A[x] -= 1
	A[y] += 1
print(sum(R))


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
b = [False, True] + [False] * (n - 1)
c = [1] * (n + 1)
for i in range(m):
	(x, y) = map(int, input().split())
	c[x] -= 1
	c[y] += 1
	if b[x]:
		b[y] = True
	if c[x] == 0:
		b[x] = False
print(sum(b))


(N, M) = map(int, input().split())
red = [0] * (N + 1)
red[1] = 1
ball = [1] * (N + 1)
for _ in range(M):
	(x, y) = map(int, input().split())
	if ball[x] == 1 and red[x] == 1:
		red[x] = 0
		red[y] = 1
	elif red[x] == 1:
		red[y] = 1
	ball[x] -= 1
	ball[y] += 1
print(sum(red))


(N, M) = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(M)]
D = [0] * N
C = [1] * N
D[0] = 1
for (x, y) in xy:
	x -= 1
	y -= 1
	if D[x] == 1:
		D[y] = 1
	C[x] -= 1
	C[y] += 1
	if C[x] == 0:
		D[x] = 0
print(sum(D))


(n, m) = map(int, input().split())
a = [[int(i) for i in input().split()] for i in range(m)]
p = ['f'] * n
p[0] = 't'
q = [1] * n
for i in range(0, m):
	q[a[i][0] - 1] -= 1
	q[a[i][1] - 1] += 1
	if p[a[i][0] - 1] == 't':
		p[a[i][1] - 1] = 't'
		if q[a[i][0] - 1] == 0:
			p[a[i][0] - 1] = 'f'
print(p.count('t'))


(N, M) = map(int, input().split())
prob = [0] * N
prob[0] = 1
num = [1] * N
num[0] = 1
for i in range(M):
	(x, y) = map(int, input().split())
	if prob[x - 1] == 1:
		prob[y - 1] = 1
	num[x - 1] -= 1
	num[y - 1] += 1
	if num[x - 1] == 0:
		prob[x - 1] = 0
print(sum(prob))


(n, m) = map(int, input().split())
num = [1 for i in range(n + 1)]
red = [False for i in range(n + 1)]
red[1] = True
for i in range(m):
	(x, y) = map(int, input().split())
	red[y] |= red[x]
	num[x] -= 1
	num[y] += 1
	if num[x] == 0:
		red[x] = False
print(red.count(True))


(n, m) = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
box = [1] * (n + 1)
red = [0] * (n + 1)
red[1] = 1
for (x, y) in xy:
	box[x] -= 1
	box[y] += 1
	if red[x] == 1:
		red[y] = 1
	if box[x] == 0:
		red[x] = 0
print(red.count(1))


(N, M) = map(int, input().split())
A = [[1, 0] for i in range(N)]
A[0][1] = 1
for i in range(M):
	(a, b) = map(int, input().split())
	if A[a - 1][1] == 1:
		A[b - 1][1] = 1
	A[a - 1][0] -= 1
	A[b - 1][0] += 1
	if A[a - 1][0] == 0:
		A[a - 1][1] = 0
ans = 0
for j in range(N):
	if A[j][1] == 1:
		ans += 1
print(ans)


(N, M) = map(int, input().split())
A = [0 for i in range(N)]
B = [1 for i in range(N)]
A[0] = 1
for i in range(M):
	(a, b) = map(int, input().split())
	B[a - 1] -= 1
	B[b - 1] += 1
	if A[a - 1] == 1:
		A[b - 1] = 1
	if B[a - 1] == 0:
		A[a - 1] = 0
print(sum(A))


(n, m) = map(int, input().split())
aka = [0] * (n + 1)
siroaka = [1] * (n + 1)
aka[1] = 1
for i in range(m):
	(x, y) = map(int, input().split())
	siroaka[x] -= 1
	siroaka[y] += 1
	if aka[x]:
		aka[y] = 1
	if siroaka[x] == 0:
		aka[x] = 0
print(sum(aka))


(n, m) = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
red = [0] * (n + 1)
red[1] = 1
ball = [1] * (n + 1)
for (x, y) in xy:
	ball[x] -= 1
	ball[y] += 1
	if red[x] == 1:
		red[y] = 1
		if ball[x] == 0:
			red[x] = 0
print(sum(red))


(N, M) = map(int, input().split())
boxes = [1] * N
ans = {1}
for i in range(M):
	(x, y) = map(int, input().split())
	boxes[x - 1] -= 1
	boxes[y - 1] += 1
	if x in ans:
		if boxes[x - 1] == 0:
			ans.remove(x)
		ans.add(y)
print(len(ans))


(N, M) = map(int, input().split())
dp = [False] * N
dp[0] = True
cnt = [1] * N
for _ in range(M):
	(x, y) = map(lambda x: int(x) - 1, input().split())
	dp[y] = dp[y] or dp[x]
	cnt[y] += 1
	cnt[x] -= 1
	if cnt[x] == 0:
		dp[x] = False
print(sum(dp))


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


(N, M) = map(int, input().split())
num = [1] * N
ex = [0] * N
ex[0] = 1
P = []
ans = 1
for i in range(M):
	(x, y) = map(int, input().split())
	num[x - 1] -= 1
	num[y - 1] += 1
	if ex[x - 1] == 1 and ex[y - 1] == 0:
		ex[y - 1] = 1
	if num[x - 1] == 0:
		ex[x - 1] = 0
print(sum(ex))


(n, m) = map(int, input().split())
red = {1}
l = [1 for _ in range(n)]
for _ in range(m):
	(x, y) = map(int, input().split())
	l[x - 1] -= 1
	l[y - 1] += 1
	if x in red:
		red.add(y)
		if l[x - 1] == 0:
			red.discard(x)
print(len(red))


(N, M) = map(int, input().split())
P = [False] * (N + 1)
P[1] = True
C = [1] * (N + 1)
for i in range(M):
	(x, y) = map(int, input().split())
	C[x] -= 1
	C[y] += 1
	if P[x]:
		P[y] = True
	if C[x] == 0:
		P[x] = False
print(P.count(True))


(n, m) = map(int, input().split())
l = []
for _ in range(m):
	l.append(list(map(int, input().split())))
a = [0] * (n + 1)
a[1] = 1
c = [1] * (n + 1)
for i in range(m):
	c[l[i][0]] -= 1
	c[l[i][1]] += 1
	if a[l[i][0]]:
		a[l[i][1]] = 1
	if c[l[i][0]] == 0:
		a[l[i][0]] = 0
print(a.count(1))


(N, M) = map(int, input().split())
xy = [list(map(int, input().split())) for _ in [0] * M]
n = [1] * N
r = [0] * N
r[0] = 1
for (x, y) in xy:
	x -= 1
	y -= 1
	n[x] -= 1
	n[y] += 1
	r[y] = r[y] or r[x]
	if n[x] == 0:
		r[x] = 0
print(sum(r))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
kosu = [1] * n
can = [0] * n
can[0] = 1
for _ in range(m):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	if can[x] == 1:
		can[y] = 1
	kosu[x] -= 1
	kosu[y] += 1
	if kosu[x] == 0:
		can[x] = 0
print(can.count(1))


(n, m) = map(int, input().split())
l = [1] * (n + 1)
r = set([1])
for i in range(m):
	(x, y) = map(int, input().split())
	if x in r:
		r.add(y)
	l[x] -= 1
	l[y] += 1
	if l[x] == 0 and x in r:
		r.remove(x)
print(len(r))


(N, M) = map(int, input().split())
P = [0] * N
C = [1] * N
P[0] = 1
for _ in range(M):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	P[y] = P[x] | P[y]
	C[x] -= 1
	C[y] += 1
	P[x] = P[x] if C[x] else 0
print(sum(P))


(N, M) = map(int, input().split())
a = [1] + [0] * (N - 1)
b = [1] * N
for i in range(M):
	(x, y) = map(int, input().split())
	if a[x - 1] == 1 and b[x - 1] == 1:
		a[x - 1] = 0
		a[y - 1] = 1
	elif a[x - 1] == 1:
		a[y - 1] = 1
	b[x - 1] -= 1
	b[y - 1] += 1
print(sum(a))


(N, M) = map(int, input().split())
R = [True] + [False] * (N - 1)
B = [1] * N
for i in range(M):
	(x, y) = map(int, input().split())
	if R[x - 1]:
		R[y - 1] = True
	B[x - 1] -= 1
	B[y - 1] += 1
	if B[x - 1] == 0:
		R[x - 1] = False
print(R.count(True))


(n, m) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
l1 = [1] * n
l2 = [1] + [0] * (n - 1)
for (x, y) in l:
	x -= 1
	y -= 1
	l1[y] += 1
	if l2[y] == 0 and l2[x] == 1:
		l2[y] = 1
	l1[x] -= 1
	if l1[x] == 0:
		l2[x] = 0
print(l2.count(1))


(n, m) = map(int, input().split())
xy = [list(map(lambda x: int(x) - 1, input().split())) for _ in [0] * m]
cnt = [1 for _ in [0] * n]
red = [False for _ in [0] * n]
red[0] = 1
for (x, y) in xy:
	cnt[x] -= 1
	cnt[y] += 1
	if red[x] == True:
		red[y] = True
	if cnt[x] == 0:
		red[x] = False
print(red.count(True))


(N, M) = map(int, input().split())
s = {1}
cnt = [1] * (N + 1)
for i in range(M):
	(x, y) = map(int, input().split())
	cnt[x] -= 1
	cnt[y] += 1
	if x in s:
		s.add(y)
		if cnt[x] == 0:
			s.discard(x)
print(len(s))


(N, M) = map(int, input().split())
XY = [[int(j) for j in input().split()] for _ in range(M)]
cnt = [1] * (N + 1)
ans = [False] * (N + 1)
ans[1] = True
for (x, y) in XY:
	cnt[x] -= 1
	cnt[y] += 1
	if ans[x] and (not ans[y]):
		ans[y] = True
	if ans[x] and cnt[x] == 0:
		ans[x] = False
print(sum(ans))


(N, M) = map(int, input().split(' '))
B = [1] * N
R = [1] + [0] * (N - 1)
for i in range(M):
	(x, y) = map(lambda x: int(x) - 1, input().split(' '))
	B[x] -= 1
	B[y] += 1
	if R[x] and B[x]:
		R[y] = 1
	elif R[x] and (not B[x]):
		R[x] = 0
		R[y] = 1
print(sum(R))


(n, m) = map(int, input().split())
r = [0] * n
r[0] = 1
c = [1] * n
for _ in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if r[x]:
		if c[x] == 1:
			r[x] = 0
		r[y] = 1
	c[x] -= 1
	c[y] += 1
print(r.count(1))


(n, m) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
l = [1] * n
red = set([0])
for i in a:
	l[i[0] - 1] -= 1
	l[i[1] - 1] += 1
	if i[0] - 1 in red:
		red.add(i[1] - 1)
		if l[i[0] - 1] == 0:
			red.remove(i[0] - 1)
print(len(red))


(n, m) = map(int, input().split())
l = [0] * (n + 1)
b = [1] * (n + 1)
l[1] = 1
for i in range(m):
	(x, y) = map(int, input().split())
	b[x] -= 1
	b[y] += 1
	l[y] = max(l[y], l[x])
	if b[x] == 0:
		l[x] = 0
print(sum(l))


(n, m) = map(int, input().split())
ball = [1] * n
flag = [1] + [0] * (n - 1)
for _ in range(m):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	ball[x] -= 1
	ball[y] += 1
	if flag[x] == 1:
		flag[y] = 1
	if ball[x] == 0:
		flag[x] = 0
print(sum(flag))


(n, m) = map(int, input().split())
ans = 0
box = [1] * n
flag = [False] * n
flag[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	box[x] -= 1
	box[y] += 1
	if flag[x]:
		flag[y] = True
	if box[x] == 0:
		flag[x] = False
print(sum(flag))


(N, M) = map(int, input().split())
ans = [0] * N
ans[0] = 1
ball = [1] * N
for _ in range(M):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if ans[x]:
		ans[y] = 1
	ball[x] -= 1
	ball[y] += 1
	if not ball[x]:
		ans[x] = 0
print(sum([i * (j > 0) for (i, j) in zip(ans, ball)]))


(n, m) = map(int, input().split())
move = [tuple(map(int, input().split())) for i in range(m)]
ball = [1] * (n + 1)
red = [False] * (n + 1)
red[1] = True
for (x, y) in move:
	ball[x] -= 1
	ball[y] += 1
	if red[x]:
		red[y] = True
	if ball[x] == 0:
		red[x] = False
ans = red.count(True)
print(ans)


(N, M) = map(int, input().split())
flags = [1] + [0] * (N - 1)
balls = [1] * N
for i in range(M):
	(x, y) = map(int, input().split())
	balls[x - 1] -= 1
	balls[y - 1] += 1
	if flags[x - 1]:
		flags[y - 1] = 1
		if balls[x - 1] == 0:
			flags[x - 1] = 0
print(sum(flags))


(N, M) = map(int, input().split())
Boxes = [1] * N
R = [False] * N
R[0] = True
for i in range(M):
	(x, y) = map(int, input().split())
	Boxes[x - 1] -= 1
	Boxes[y - 1] += 1
	if R[x - 1]:
		R[y - 1] = True
	if Boxes[x - 1] == 0:
		R[x - 1] = False
ans = 0
for i in range(N):
	if R[i]:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
ans = [False] * n
ans[0] = True
co = [1] * n
for i in range(m):
	(x, y) = map(int, input().split())
	ans[y - 1] |= ans[x - 1]
	co[x - 1] -= 1
	co[y - 1] += 1
	if co[x - 1] == 0:
		ans[x - 1] = False
print(ans.count(True))


(N, M) = map(int, input().split())
num = [1] * N
red = [0] * N
red[0] = 1
for _ in range(M):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	num[x] -= 1
	num[y] += 1
	red[y] |= red[x]
	if num[x] == 0:
		red[x] = 0
ans = sum(red)
print(ans)


(N, M) = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(M)]
b = [1] * N
r = [1] + [0] * (N - 1)
for (x, y) in xy:
	b[x - 1] -= 1
	b[y - 1] += 1
	if r[x - 1] == 1:
		r[y - 1] = 1
		if b[x - 1] == 0:
			r[x - 1] = 0
print(sum(r))


(n, m) = map(int, input().split())
canred = set()
canred.add(1)
balls = [1 for i in range(n)]
for i in range(m):
	(x, y) = map(int, input().split())
	if x in canred:
		canred.add(y)
	balls[x - 1] -= 1
	balls[y - 1] += 1
	if balls[x - 1] == 0:
		canred.discard(x)
print(len(canred))


(n, m) = map(int, input().split())
r = [0] * (n + 1)
r[1] = 1
b0 = [1] * (n + 1)
for i in range(m):
	(x, y) = map(int, input().split())
	b0[x] -= 1
	b0[y] += 1
	if r[x]:
		r[y] = 1
	if b0[x] == 0:
		r[x] = 0
ans = 0
for j in range(n + 1):
	if r[j]:
		ans += 1
print(ans)


(n, m) = map(int, input().split())
b1 = [1] * n
b2 = [0] * n
b2[0] = 1
for i in range(m):
	(x, y) = map(int, input().split())
	if 1 <= b1[x - 1]:
		b1[x - 1] -= 1
		b1[y - 1] += 1
		if 1 <= b2[x - 1]:
			b2[y - 1] = 1
		if 0 == b1[x - 1]:
			b2[x - 1] = 0
print(sum(b2))


(n, m) = map(int, input().split())
b = [1] * n
red = [False] * n
red[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	if not b[x]:
		continue
	b[y] += 1
	if red[x]:
		red[y] = True
	b[x] -= 1
	if b[x] == 0:
		red[x] = False
print(red.count(True))


(N, M) = map(int, input().split())
flag = [0] * N
ball = [1] * N
flag[0] = 1
for _ in range(M):
	(x, y) = map(int, input().split())
	ball[x - 1] -= 1
	ball[y - 1] += 1
	if flag[x - 1] == 1:
		flag[y - 1] = 1
	if ball[x - 1] == 0:
		flag[x - 1] = 0
print(sum(flag))


(N, M) = map(int, input().split())
Red = [False] * N
Cnt = [1] * N
Red[0] = True
for i in range(M):
	(x, y) = map(lambda x: int(x) - 1, input().split())
	Red[y] |= Red[x]
	Cnt[y] += 1
	Cnt[x] -= 1
	if Cnt[x] == 0:
		Red[x] = False
ans = 0
for i in range(N):
	if Red[i] and Cnt[i] > 0:
		ans += 1
print(ans)


(N, M) = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(M)]
L1 = [1] * N
L2 = [0] * N
L2[0] = 1
for xy in XY:
	if L2[xy[0] - 1] == 1:
		L2[xy[1] - 1] = 1
	L1[xy[0] - 1] -= 1
	L1[xy[1] - 1] += 1
	if L1[xy[0] - 1] == 0:
		L2[xy[0] - 1] = 0
print(sum(L2))


(N, M) = map(int, input().split())
ans = set([0])
cnt = [1] * N
for _ in range(M):
	(x, y) = [int(i) - 1 for i in input().split()]
	cnt[x] -= 1
	cnt[y] += 1
	if x in ans:
		ans.add(y)
		if cnt[x] == 0:
			ans.remove(x)
print(len(ans))


(N, M) = map(int, input().split())
box = [1] * N
red = [0] * N
red[0] = 1
for i in range(M):
	(a, b) = map(int, input().split())
	box[a - 1] -= 1
	box[b - 1] += 1
	if red[a - 1] == 1:
		red[b - 1] = 1
	if box[a - 1] == 0:
		red[a - 1] = 0
print(sum(red))


(n, m) = map(int, input().split())
c = [1 for i in range(n)]
p = [0 for i in range(n)]
p[0] = 1
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	c[x] -= 1
	c[y] += 1
	if p[x] == 1:
		p[y] = 1
	if c[x] == 0:
		p[x] = 0
print(p.count(1))


(n, m) = map(int, input().split())
numl = [1] * n
l = [False] * n
l[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	numl[x] -= 1
	numl[y] += 1
	if l[x]:
		l[y] = True
		if numl[x] == 0:
			l[x] = False
print(l.count(True))


(n, m) = map(int, input().split())
counts = [1] * n
cands = [False] * n
cands[0] = True
for _ in range(m):
	(x, y) = map(lambda t: int(t) - 1, input().split())
	counts[x] -= 1
	counts[y] += 1
	if cands[x]:
		cands[y] = True
		if counts[x] == 0:
			cands[x] = False
print(sum(cands))


(N, M) = map(int, input().split())
num = [1] * N
red = [False] * N
red[0] = True
for i in range(M):
	(x, y) = map(int, input().split())
	if red[x - 1]:
		red[y - 1] = True
	num[x - 1] -= 1
	num[y - 1] += 1
	if num[x - 1] == 0:
		red[x - 1] = False
print(red.count(True))


(n, m) = map(int, input().split())
cnt = [1] * n
s = set([1])
for i in range(m):
	(x, y) = map(int, input().split())
	cnt[y - 1] += 1
	cnt[x - 1] -= 1
	if x in s:
		s.add(y)
	if cnt[x - 1] == 0:
		if x in s:
			s.remove(x)
print(len(s))


(N, M) = map(int, input().split())
box = [1] * N
P = [1] + [0] * (N - 1)
for i in range(M):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	box[x] -= 1
	box[y] += 1
	if P[x] == 1:
		P[y] = 1
		if box[x] == 0:
			P[x] = 0
print(sum(P))


(n, m) = map(int, input().split())
li = [1] * (n + 1)
se = set()
se.add(1)
for i in range(m):
	(x, y) = map(int, input().split())
	li[x] -= 1
	li[y] += 1
	if x in se:
		se.add(y)
		if li[x] == 0:
			se.remove(x)
print(len(se))


(n, m) = map(int, input().split())
N = [1] * n
P = [True] + [False] * (n - 1)
for i in range(m):
	(x, y) = list(map(lambda tmp: tmp - 1, map(int, input().split())))
	P[y] = True if P[x] == True else P[y]
	N[x] -= 1
	N[y] += 1
	P[x] = False if N[x] == 0 else P[x]
print(sum(P))


(n, m) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(m)]
count = [1] * (n + 1)
flag = [False] * (n + 1)
flag[1] = True
for (a, b) in arr:
	count[b] += 1
	count[a] -= 1
	if flag[a] == True:
		flag[b] = True
	if count[a] == 0:
		flag[a] = False
print(flag.count(True))


(N, M) = map(int, input().split())
table = []
for i in range(M):
	(x, y) = map(int, input().split())
	table.append((x - 1, y - 1))
F = [False] * N
F[0] = True
L = [1] * N
for (x, y) in table:
	L[x] -= 1
	L[y] += 1
	if F[x]:
		F[y] = True
	if L[x] == 0:
		F[x] = False
print(sum(F))


(n, m) = map(int, input().split())
num = [1] * n
r = [1] + [0] * (n - 1)
for _ in range(m):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	num[x] -= 1
	num[y] += 1
	if r[x]:
		r[y] = 1
	if num[x] == 0:
		r[x] = 0
print(sum(r))


(N, M) = map(int, input().split())
balls = [1] * (N + 1)
reds = [False] * (N + 1)
reds[0] = True
for i in range(M):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	balls[x] -= 1
	balls[y] += 1
	if reds[x]:
		reds[y] = True
	if balls[x] == 0:
		reds[x] = False
print(sum(reds))


(n, m) = map(int, input().split())
l = [1] * n
d = set()
d.add(1)
for i in range(m):
	(x, y) = map(int, input().split())
	l[x - 1] -= 1
	l[y - 1] += 1
	if x in d:
		d.add(y)
		if l[x - 1] == 0:
			d.remove(x)
s = 0
for i in d:
	if l[i - 1] != 0:
		s += 1
print(s)


(n, m) = map(int, input().split())
l = [list(map(int, input().split())) for i in range(m)]
f = [1] * n
ans = [0] * n
ans[0] = 1
for i in range(m):
	if ans[l[i][0] - 1] == 1:
		if f[l[i][0] - 1] == 1:
			ans[l[i][0] - 1] = 0
			ans[l[i][1] - 1] = 1
		else:
			ans[l[i][1] - 1] = 1
	f[l[i][0] - 1] -= 1
	f[l[i][1] - 1] += 1
print(sum(ans))


(n, m) = map(int, input().split())
a = [1] * n
ans = set([1])
for i in range(m):
	(x, y) = map(int, input().split())
	if a[x - 1] == 0:
		continue
	else:
		a[x - 1] -= 1
		a[y - 1] += 1
		if x in ans:
			ans.add(y)
			if a[x - 1] == 0:
				ans.remove(x)
print(len(ans))


(N, M) = map(int, input().split())
ans = [0] * N
ans[0] = 1
w = [1] * N
for i in range(M):
	(x, y) = map(int, input().split())
	w[x - 1] -= 1
	w[y - 1] += 1
	if ans[x - 1] == 1:
		ans[y - 1] = 1
		if w[x - 1] == 0:
			ans[x - 1] = 0
print(sum(ans))


(n, m) = map(int, input().split())
p = [1] * n
c = ['w'] * n
c[0] = 'r'

def ope(x, y):
	if c[x - 1] == 'r':
		c[y - 1] = 'r'
	p[x - 1] -= 1
	p[y - 1] += 1
	if p[x - 1] == 0:
		c[x - 1] = 'w'
for i in range(m):
	(x, y) = map(int, input().split())
	ope(x, y)
print(c.count('r'))


(N, M) = map(int, input().split())
X = [0] * (N + 1)
X[1] = 1
Y = [1] * (N + 1)
(a, b) = (0, 0)
for i in range(M):
	(a, b) = map(int, input().split())
	X[b] |= X[a]
	Y[b] += 1
	Y[a] -= 1
	if Y[a] == 0:
		X[a] = 0
print(sum(X))


(N, M) = list(map(int, input().split()))
dot = [1] * N
sw = [0] * N
sw[0] = 1
for i in range(M):
	(a, b) = list(map(int, input().split()))
	a -= 1
	b -= 1
	dot[a] -= 1
	dot[b] += 1
	if sw[a]:
		sw[b] = 1
	if dot[a] == 0:
		sw[a] = 0
print(sw.count(1))


(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
amt = [1 for i in range(n)]
red = [i == 0 for i in range(n)]
for i in range(m):
	(a, b) = input().split(' ')
	(a, b) = (int(a), int(b))
	a -= 1
	b -= 1
	amt[a] -= 1
	amt[b] += 1
	red[b] |= red[a]
	if amt[a] == 0:
		red[a] = False
print(sum(red))


(n, m) = (int(i) for i in input().split())
x = [[int(i) for i in input().split()] for i in range(m)]
(red, num) = (set([1]), [1 for i in range(n + 1)])
for (i, j) in x:
	(num[i], num[j]) = (num[i] - 1, num[j] + 1)
	if i in red:
		red.add(j)
		if num[i] == 0:
			red.remove(i)
print(len(red))


(N, M) = list(map(int, input().split()))
XY = [list(map(int, input().split())) for _ in range(M)]
red = set([1])
n_ball = [1] * (N + 1)
for (x, y) in XY:
	n_ball[x] -= 1
	n_ball[y] += 1
	if x in red:
		red.add(y)
		if n_ball[x] == 0:
			red.remove(x)
print(len(red))


(n, m) = map(int, input().split())
A = [False] * n
B = [1] * n
A[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	if A[x - 1]:
		A[y - 1] = True
	B[x - 1] -= 1
	B[y - 1] += 1
	if B[x - 1] == 0:
		A[x - 1] = False
print(A.count(True))


(n, m) = map(int, input().split())
a = [1] * (n + 1)
b = [0] * (n + 1)
b[1] = 1
for _ in range(m):
	(x, y) = map(int, input().split())
	a[x] -= 1
	a[y] += 1
	if b[x]:
		b[y] = 1
	if a[x] == 0:
		b[x] = 0
ans = 0
for (i, j) in zip(a, b):
	ans += (i != 0) * j
print(ans)


(n, m) = map(int, input().split())
r = [False] * n
c = [1] * n
r[0] = True
for _ in range(m):
	(x, y) = map(lambda n: int(n) - 1, input().split())
	if r[x]:
		r[y] = True
	c[x] -= 1
	c[y] += 1
	if c[x] == 0:
		r[x] = False
print(sum(r))


(N, M) = map(int, input().split())
ball = [1] * N
red = {1}
ans = 0
for _ in range(M):
	(x, y) = map(int, input().split())
	ball[x - 1] -= 1
	ball[y - 1] += 1
	if x in red:
		red.add(y)
		if ball[x - 1] == 0:
			red.remove(x)
print(len(red))


(n, m) = map(int, input().split())
data = [1] * n
d = [1] + [0] * (n - 1)
for i in range(m):
	(x, y) = map(int, input().split())
	data[x - 1] -= 1
	data[y - 1] += 1
	if d[x - 1] == 1:
		d[y - 1] = 1
	if data[x - 1] == 0:
		d[x - 1] = 0
print(d.count(1))


(a, b) = map(int, input().split())
n = [1] * a
r = [0] * a
r[0] = 1
for i in range(b):
	(ta, tb) = map(int, input().split())
	ta -= 1
	tb -= 1
	if r[ta] == 1:
		r[tb] = 1
	n[ta] -= 1
	n[tb] += 1
	if n[ta] == 0:
		r[ta] = 0
print(sum(r))


(N, M) = map(int, input().split())
li = [1] * N
ri = [0] * N
ri[0] = 1
for i in range(M):
	(x, y) = map(int, input().split())
	if ri[x - 1] == 1:
		ri[y - 1] = 1
	li[x - 1] -= 1
	li[y - 1] += 1
	if li[x - 1] == 0:
		ri[x - 1] = 0
print(sum(ri))


(N, M) = map(int, input().split())
flg = [0] * (N + 1)
flg[1] = 1
flg2 = [1] * (N + 1)
for _ in range(M):
	xy = list(map(int, input().split()))
	if flg[xy[0]] == 1:
		flg[xy[1]] = 1
	flg2[xy[1]] += 1
	flg2[xy[0]] -= 1
	if flg2[xy[0]] == 0:
		flg[xy[0]] = 0
print(sum(map(lambda x: x > 0, flg)))


(N, M) = map(int, input().split())
red = [0] * N
red[0] = 1
q = [1] * N
for _ in range(M):
	(x, y) = map(int, input().split())
	red[y - 1] |= red[x - 1]
	q[x - 1] -= 1
	q[y - 1] += 1
	if q[x - 1] == 0:
		red[x - 1] = 0
print(sum([1 for i in range(N) if q[i] > 0 and red[i]]))


(n, m) = list(map(int, input().split()))
B = [1] * n
R = [False] * n
R[0] = True
for i in range(m):
	(x, y) = list(map(int, input().split()))
	B[y - 1] += 1
	B[x - 1] -= 1
	if R[x - 1] == True:
		if B[x - 1] == 0:
			R[x - 1] = False
			R[y - 1] = True
		else:
			R[y - 1] = True
print(R.count(True))


(n, m) = map(int, input().split())
xy = [list(map(int, input().split())) for _ in range(m)]
cnt = [1] * n
r = [1] + [0] * (n - 1)
for (x, y) in xy:
	cnt[x - 1] -= 1
	cnt[y - 1] += 1
	if r[x - 1] == 1:
		r[y - 1] = 1
	if cnt[x - 1] == 0:
		r[x - 1] = 0
print(sum(r))


(N, M) = map(int, input().split())
XY = [list(map(int, input().split())) for _ in [0] * M]
R = [False] * N
R[0] = True
B = [1] * N
for (x, y) in XY:
	x -= 1
	y -= 1
	B[y] += 1
	B[x] -= 1
	R[y] = R[y] or R[x]
	R[x] = R[x] and B[x] > 0
print(sum(R))


(n, m) = map(int, input().split())
r = [False] * n
l = [1] * n
r[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if r[x]:
		r[y] = True
	l[x] -= 1
	l[y] += 1
	if l[x] == 0:
		r[x] = False
s = 0
for i in range(n):
	if r[i]:
		if l[i]:
			s += 1
print(s)


(N, M) = map(int, input().split())
B = [1 for i in range(N)]
P = set([1])
for i in range(M):
	(x, y) = map(int, input().split())
	B[x - 1] -= 1
	B[y - 1] += 1
	if x in P:
		P.add(y)
	if B[x - 1] == 0 and x in P:
		P.remove(x)
print(len(P))


(N, M) = map(int, input().split())
y_if = {1}
num = [1] * N
for i in range(M):
	(x, y) = map(int, input().split())
	num[x - 1] -= 1
	num[y - 1] += 1
	if x in y_if:
		if num[x - 1] == 0:
			y_if.remove(x)
		y_if.add(y)
print(len(y_if))


(n, m) = map(int, input().split())
checker = [1 for _i in range(n + 1)]
r = [0 for i in range(n + 1)]
r[1] = 1
for _i in range(m):
	(x, y) = map(int, input().split())
	checker[x] -= 1
	checker[y] += 1
	if r[x] > 0:
		r[y] = 1
	if r[x] > 0 and checker[x] == 0:
		r[x] = 0
print(sum(r))


(n, m) = map(int, input().split())
arr = [list(map(int, input().split())) for _ in range(m)]
count = [1] * (n + 1)
s = set()
s.add(1)
for (a, b) in arr:
	count[b] += 1
	count[a] -= 1
	if a in s:
		s.add(b)
	if count[a] == 0:
		s.discard(a)
print(len(s))


(n, m) = (int(i) for i in input().split())
dp = [0] * (n + 1)
ball = [1] * (n + 1)
dp[0] = 1
for i in range(m):
	(x, y) = (int(i) for i in input().split())
	if dp[x - 1] == 1:
		dp[y - 1] = 1
	ball[x - 1] -= 1
	ball[y - 1] += 1
	if ball[x - 1] == 0:
		dp[x - 1] = 0
print(sum(dp))


(n, m) = map(int, input().split())
cnt = [1] * n
red = [0] * n
red[0] = 1
for _ in range(m):
	(x, y) = map(lambda x: int(x) - 1, input().split())
	cnt[x] -= 1
	cnt[y] += 1
	if red[x]:
		red[y] = 1
		if cnt[x] == 0:
			red[x] = 0
print(sum(red))


(N, M) = map(int, input().split())
XY = [tuple(map(int, input().split())) for i in range(M)]
rs = [0] * N
rs[0] = 1
cs = [1] * N
for (x, y) in XY:
	(x, y) = (x - 1, y - 1)
	if rs[x]:
		if cs[x] == 1:
			rs[x] = 0
		rs[y] = 1
	cs[x] -= 1
	cs[y] += 1
print(sum(rs))


(n, m) = map(int, input().split())
bc = [1] * n
bt = [0] * n
bt[0] = 1
for _ in range(m):
	(x, y) = map(int, input().split())
	(x, y) = (x - 1, y - 1)
	bc[x] -= 1
	bc[y] += 1
	bt[y] |= bt[x]
	if bc[x] == 0:
		bt[x] = 0
print(sum(bt))


(N, M) = map(int, input().split())
A = [[0] * N, [1] * N]
A[0][0] = 1
A[1][0] = 0
for i in range(M):
	(x, y) = map(int, input().split())
	if A[0][x - 1] > 0:
		A[0][y - 1] += 1
	else:
		A[1][y - 1] += 1
	if A[1][x - 1] > 0:
		A[1][x - 1] -= 1
	else:
		A[0][x - 1] -= 1
print(len([i for i in A[0] if i > 0]))


(N, M) = map(int, input().split())
Red = [0] * N
Red[0] = 1
Num = [1] * N
for i in range(M):
	(In, Out) = map(int, input().split())
	In -= 1
	Out -= 1
	Num[In] -= 1
	Num[Out] += 1
	if Red[In]:
		Red[Out] = 1
	if Num[In] == 0:
		Red[In] = 0
print(sum(Red))


(n, m) = map(int, input().split())
tama = [1] * n
red = [False] * n
red[0] = True
for i in range(m):
	(x, y) = map(int, input().split())
	tama[x - 1] -= 1
	tama[y - 1] += 1
	red[y - 1] = red[y - 1] or red[x - 1]
	if tama[x - 1] == 0:
		red[x - 1] = False
print(sum(red))


(N, M) = map(int, input().split())
L = [1] * N
S = [-1] * N
S[0] = 1
for i in range(M):
	(x, y) = map(int, input().split())
	if S[x - 1] == 1:
		S[y - 1] = 1
	L[x - 1] -= 1
	L[y - 1] += 1
	if L[x - 1] == 0:
		S[x - 1] = -1
print(S.count(1))


(n, m) = map(int, input().split())
L = [1] * n
R = [1] + [0] * ~-n
for _ in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if R[x]:
		R[y] = 1
	L[x] -= 1
	L[y] += 1
	R[x] *= L[x] > 0
print(sum(R))


(n, m) = map(int, input().split())
red = [1] + [0] * (n - 1)
pink = [1] * n
for _ in range(m):
	(x, y) = map(int, input().split())
	x -= 1
	y -= 1
	if red[x] and pink[x] == 1:
		red[x] = 0
		red[y] = 1
	elif red[x] and pink[x] > 1:
		red[y] = 1
	pink[x] -= 1
	pink[y] += 1
print(red.count(1))