py3 代码 哈希表
from collections import defaultdict
[n, k] = list(map(int, input().split()))
dic = defaultdict(bool)
dic[0] = True
ans = 0
for _ in range(k):
[x, y] = list(map(int, input().split()))
if not dic[y]:
ans = ans + 1
dic[x] = True
print(ans)