import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    }
} import java.util.ArrayList; ArrayList java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    }
} Main public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    } main {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int sunukeNum = sc.nextInt(); sunukeNum sc.nextInt() sc.nextInt sc int sweetsNum = sc.nextInt(); sweetsNum sc.nextInt() sc.nextInt sc List<Integer> hasSweetsSunuke = new ArrayList<>(); hasSweetsSunuke new ArrayList<>() for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        } int i = 0; int i = 0; i 0 i < sunukeNum i sunukeNum i++ i++ i {
            hasSweetsSunuke.add(0);
        } {
            hasSweetsSunuke.add(0);
        } hasSweetsSunuke.add(0) hasSweetsSunuke.add hasSweetsSunuke 0 int trickNum = sunukeNum; trickNum sunukeNum for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        } int i = 0; int i = 0; i 0 i < sweetsNum i sweetsNum i++ i++ i {
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        } {
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        } int sweetsNo = sc.nextInt(); sweetsNo sc.nextInt() sc.nextInt sc for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            } int j = 0; int j = 0; j 0 j < sweetsNo j sweetsNo j++ j++ j {
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            } {
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            } int sunukeNo = sc.nextInt()-1; sunukeNo sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                } hasSweetsSunuke.get(sunukeNo) == 0 hasSweetsSunuke.get(sunukeNo) hasSweetsSunuke.get hasSweetsSunuke sunukeNo 0 {
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                } hasSweetsSunuke.set(sunukeNo, 1) hasSweetsSunuke.set hasSweetsSunuke sunukeNo 1 trickNum-- trickNum if(trickNum == 0){
                System.out.println(0);
                return;
            } trickNum == 0 trickNum 0 {
                System.out.println(0);
                return;
            } System.out.println(0) System.out.println System.out System System.out 0 return; System.out.println(trickNum) System.out.println System.out System System.out trickNum String[] args args public class Main {

    public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    }
} public class Main {

    public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // input N K d1 A11,A12,...,A1d1 d2 ... AKdK
        // Aij の割当がない番号の個数を出力せよ
        Scanner sc = new Scanner(System.in);
        int sunukeNum = sc.nextInt();
        int sweetsNum = sc.nextInt();
        List<Integer> hasSweetsSunuke = new ArrayList<>();
        for(int i = 0; i < sunukeNum; i++){
            hasSweetsSunuke.add(0);
        }
        int trickNum = sunukeNum;
        for(int i = 0; i < sweetsNum; i++){
            int sweetsNo = sc.nextInt();
            for(int j = 0; j < sweetsNo; j++){
                int sunukeNo = sc.nextInt()-1;
                if(hasSweetsSunuke.get(sunukeNo) == 0){
                    hasSweetsSunuke.set(sunukeNo, 1);
                    trickNum--;
                }
            }
            if(trickNum == 0){
                System.out.println(0);
                return;
            }
        }
        System.out.println(trickNum);
    }
}