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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
} 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 sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

		System.out.println(cnt);
	} main {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc List<List<Integer>> lists = new ArrayList<List<Integer>>(); lists new ArrayList<List<Integer>>() for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		} {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		} int head = sc.nextInt(); head sc.nextInt() sc.nextInt sc List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			} int j = 0; int j = 0; j 0 j < head j head j++ j++ j {
				list.add(sc.nextInt());
			} {
				list.add(sc.nextInt());
			} list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc lists.add(list) lists.add lists list if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		} lists.size()==1 lists.size() lists.size lists 1 {
			System.out.println(lists.get(0).size());
			return;
		} System.out.println(lists.get(0).size()) System.out.println System.out System System.out lists.get(0).size() lists.get(0).size lists.get(0) lists.get lists 0 return; int cnt = 0; cnt 0 List<Integer> tmp = lists.get(0); tmp lists.get(0) lists.get lists 0 for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		} int j = 0; int j = 0; j 0 j < tmp.size() j tmp.size() tmp.size tmp j++ j++ j {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		} {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		} int check = tmp.get(j); check tmp.get(j) tmp.get tmp j boolean flag = false; flag false for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			} int p = 0; int p = 0; p 0 p < lists.size() p lists.size() lists.size lists p++ p++ p {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			} {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			} if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				} lists.get(p) == tmp lists.get(p) lists.get lists p tmp {
					continue;
				} continue; {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				} if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					} lists.get(p).contains(check) lists.get(p).contains lists.get(p) lists.get lists p check {
						flag = true;
					} flag = true flag true {
						flag = false;
						break;
					} flag = false flag false break; if (flag == true) {
				cnt++;
			} flag == true flag true {
				cnt++;
			} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		List<List<Integer>> lists = new ArrayList<List<Integer>>();
		for (int i = 0; i < n; i++) {
			int head = sc.nextInt();
			List<Integer> list = new ArrayList<Integer>();
			for (int j = 0; j < head; j++) {
				list.add(sc.nextInt());
			}
			lists.add(list);
		}
		if(lists.size()==1) {
			System.out.println(lists.get(0).size());
			return;
		}
		int cnt = 0;
		List<Integer> tmp = lists.get(0);
		for (int j = 0; j < tmp.size(); j++) {
			int check = tmp.get(j);
			boolean flag = false;
			for (int p = 0; p < lists.size(); p++) {
				if (lists.get(p) == tmp) {
					continue;
				} else {
					if (lists.get(p).contains(check)) {
						flag = true;
					} else {
						flag = false;
						break;
					}
				}
			}
			if (flag == true) {
				cnt++;
			}
		}

		System.out.println(cnt);
	}
}
