import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
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();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	}
} import java.util.ArrayList; ArrayList java.util import java.util.HashMap; HashMap java.util import java.util.Map.Entry; Entry java.util.Map 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();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	} 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 HashMap<Integer, Integer> map = new HashMap<>(); map new HashMap<>() int k[] = new int[n]; k new int[n] n int a[][] = new int[n][m]; a new int[n][m] n m for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		} {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		} k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			} int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			} {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			} a[i][j] = sc.nextInt() a[i][j] a[i] a i j sc.nextInt() sc.nextInt sc Integer cnt = map.get(a[i][j]); cnt map.get(a[i][j]) map.get map a[i][j] a[i] a i j if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				} cnt == null cnt null {
					map.put(a[i][j],1);
				} map.put(a[i][j],1) map.put map a[i][j] a[i] a i j 1 {
					map.put(a[i][j],cnt + 1);
				} map.put(a[i][j],cnt + 1) map.put map a[i][j] a[i] a i j cnt + 1 cnt 1 ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet()); list new ArrayList<Entry<Integer,Integer>>(map.entrySet()) int ans = 0; ans 0 for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		} Entry e list {
			if ((int)e.getValue() == n) {
				ans++;
			}
		} {
			if ((int)e.getValue() == n) {
				ans++;
			}
		} if ((int)e.getValue() == n) {
				ans++;
			} (int)e.getValue() == n (int)e.getValue() e.getValue e n {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	}
} Main
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map.Entry;
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();

		HashMap<Integer, Integer> map = new HashMap<>();

		int k[] = new int[n];
		int a[][] = new int[n][m];

		for (int i = 0; i < n; i++) {
			k[i] = sc.nextInt();
			for (int j = 0; j < k[i]; j++) {
				a[i][j] = sc.nextInt();

				Integer cnt = map.get(a[i][j]);
				if (cnt == null) {
					map.put(a[i][j],1);
				} else {
					map.put(a[i][j],cnt + 1);
				}
			}
		}

		ArrayList<Entry<Integer, Integer>> list = new ArrayList<Entry<Integer,Integer>>(map.entrySet());

		int ans = 0;
		for(Entry e: list) {
			if ((int)e.getValue() == n) {
				ans++;
			}
		}

	System.out.println(ans);
	}
}
