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