import java.util.Scanner; class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int M = sc.nextInt(); int[] ind = new int[N]; int ans = N; while(M-->0){ sc.next(); int B = sc.nextInt()-1; if(ind[B]++==0) --ans; } System.out.println(ans); } }