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

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	}
} 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) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	}
} Main public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	} main {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	} Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner List<Integer> alList = new ArrayList<>(); alList new ArrayList<>() for (int i = 1; i <= M; i++) {
			alList.add(i);
		} int i = 1; int i = 1; i 1 i <= M i M i++ i++ i {
			alList.add(i);
		} {
			alList.add(i);
		} alList.add(i) alList.add alList i while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		} scanner.hasNextLine() scanner.hasNextLine scanner {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		} scanner.nextInt() scanner.nextInt scanner String string = scanner.nextLine(); string scanner.nextLine() scanner.nextLine scanner String[] s = string.split(" "); s string.split(" ") string.split string " " List<String> kIntegers = new ArrayList<>(); kIntegers new ArrayList<>() for (String k : s) {
				kIntegers.add(k);
			} String k s {
				kIntegers.add(k);
			} {
				kIntegers.add(k);
			} kIntegers.add(k) kIntegers.add kIntegers k List<Integer> nothing = new ArrayList<>(); nothing new ArrayList<>() for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			} int i = 1; int i = 1; i 1 i <= M i M i++ i++ i {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			} {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			} if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				} !kIntegers.contains(String.valueOf(i)) kIntegers.contains(String.valueOf(i)) kIntegers.contains kIntegers String.valueOf(i) String.valueOf String i {
					nothing.add(i);
				} nothing.add(i) nothing.add nothing i alList.removeAll(nothing) alList.removeAll alList nothing System.out.println(alList.size()) System.out.println System.out System System.out alList.size() alList.size alList String[] args args public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	}
} public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	}
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int M = scanner.nextInt();
		scanner.nextLine();
		List<Integer> alList = new ArrayList<>();
		for (int i = 1; i <= M; i++) {
			alList.add(i);
		}

		while (scanner.hasNextLine()) {
			scanner.nextInt();
			String string = scanner.nextLine();
			String[] s = string.split(" ");
			List<String> kIntegers = new ArrayList<>();
			for (String k : s) {
				kIntegers.add(k);
			}
			List<Integer> nothing = new ArrayList<>();
			for (int i = 1; i <= M; i++) {
				if (!kIntegers.contains(String.valueOf(i))) {
					nothing.add(i);
				}
			}

			alList.removeAll(nothing);
		}

		System.out.println(alList.size());
	}
}