import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	}
} import java.util.HashSet; HashSet java.util import java.util.Scanner; Scanner java.util import java.util.Set; Set java.util public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	}
} Main public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	} main {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	} try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		} {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		} Scanner scanner = new Scanner(System.in) Scanner scanner = new Scanner(System.in) new Scanner(System.in) int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner Set<Integer> commonSet = new HashSet<>(); commonSet new HashSet<>() for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			} {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			} int number = scanner.nextInt(); number scanner.nextInt() scanner.nextInt scanner Set<Integer> set = new HashSet<>(); set new HashSet<>() for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				} int j = 0; int j = 0; j 0 j < number j number j++ j++ j {
					set.add(scanner.nextInt());
				} {
					set.add(scanner.nextInt());
				} set.add(scanner.nextInt()) set.add set scanner.nextInt() scanner.nextInt scanner scanner.nextLine() scanner.nextLine scanner if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				} 0 == i 0 i {
					commonSet.addAll(set);
				} commonSet.addAll(set) commonSet.addAll commonSet set {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				} Set<Integer> removeSet = new HashSet<>(); removeSet new HashSet<>() for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					} Integer integer commonSet {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					} {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					} if (!set.contains(integer)) {
							removeSet.add(integer);
						} !set.contains(integer) set.contains(integer) set.contains set integer {
							removeSet.add(integer);
						} removeSet.add(integer) removeSet.add removeSet integer commonSet.removeAll(removeSet) commonSet.removeAll commonSet removeSet System.out.println(commonSet.size()) System.out.println System.out System System.out commonSet.size() commonSet.size commonSet String[] args args public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	}
} public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	}
} Main
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			scanner.nextInt();
			scanner.nextLine();
			Set<Integer> commonSet = new HashSet<>();
			for (int i = 0; i < n; i++) {
				int number = scanner.nextInt();
				Set<Integer> set = new HashSet<>();
				for (int j = 0; j < number; j++) {
					set.add(scanner.nextInt());
				}
				scanner.nextLine();
				if (0 == i) {
					commonSet.addAll(set);
				} else {
					Set<Integer> removeSet = new HashSet<>();
					for (Integer integer : commonSet) {
						if (!set.contains(integer)) {
							removeSet.add(integer);
						}
					}
					commonSet.removeAll(removeSet);
				}
			}
			System.out.println(commonSet.size());
		}
	}
}
