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

public class Main {
	public static void main(String[] args) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.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) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	}
} Main public static void main(String[] args) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	} main {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	} Set<Integer> list = new HashSet<>(); list new HashSet<>() int persons; persons try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		} {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		} Scanner sc = new Scanner(System.in) Scanner sc = new Scanner(System.in) new Scanner(System.in) persons = sc.nextInt() persons sc.nextInt() sc.nextInt sc sc.nextInt() sc.nextInt sc int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			} int i = 0; int i = 0; i 0 i < num i num i++ i++ i {
				list.add(sc.nextInt());
			} {
				list.add(sc.nextInt());
			} list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			} int p = 0; int p = 0; p 0 p < persons - 1 p persons - 1 persons 1 p++ p++ p {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			} {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			} int num1 = sc.nextInt(); num1 sc.nextInt() sc.nextInt sc Set<Integer> templist = new HashSet<>(); templist new HashSet<>() for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				} int i = 0; int i = 0; i 0 i < num1 i num1 i++ i++ i {
					templist.add(sc.nextInt());
				} {
					templist.add(sc.nextInt());
				} templist.add(sc.nextInt()) templist.add templist sc.nextInt() sc.nextInt sc list.retainAll(templist) list.retainAll list templist System.out.println(list.size()) System.out.println System.out System System.out list.size() list.size list String[] args args public class Main {
	public static void main(String[] args) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	}
} public class Main {
	public static void main(String[] args) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	}
} Main
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Set<Integer> list = new HashSet<>();
		int persons;
		try (Scanner sc = new Scanner(System.in);) {
			// 最初の一回は空振り
			persons = sc.nextInt();
			sc.nextInt();
			// 1人目
			int num = sc.nextInt();
			for (int i = 0; i < num; i++) {
				list.add(sc.nextInt());
			}
			for (int p = 0; p < persons - 1; p++) {
				int num1 = sc.nextInt();
				Set<Integer> templist = new HashSet<>();
				for (int i = 0; i < num1; i++) {
					templist.add(sc.nextInt());
				}
				list.retainAll(templist);
			}
		}
		System.out.println(list.size());
	}
}