import java.util.Arrays;
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();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	}
} import java.util.Arrays; Arrays 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();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	} 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 int ans; ans int fod[] = new int[m + 1]; fod new int[m + 1] m + 1 m 1 Arrays.fill(fod, 0) Arrays.fill Arrays fod 0 int you = 0; you 0 for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		} int i = 1; int i = 1; i 1 i <= n i n i++ i++ i {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		} {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		} you = sc.nextInt() you sc.nextInt() sc.nextInt sc for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			} int s = 1; int s = 1; s 1 s <= you s you s++ s++ s {
				ans = sc.nextInt();
				fod[ans]++;

			} {
				ans = sc.nextInt();
				fod[ans]++;

			} ans = sc.nextInt() ans sc.nextInt() sc.nextInt sc fod[ans]++ fod[ans] fod ans int kotae = 0; kotae 0 for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		} int i = 0; int i = 0; i 0 i <= m i m i++ i++ i {
			if (fod[i] == n) {
				kotae++;
			}
		} {
			if (fod[i] == n) {
				kotae++;
			}
		} if (fod[i] == n) {
				kotae++;
			} fod[i] == n fod[i] fod i n {
				kotae++;
			} kotae++ kotae System.out.println(kotae) System.out.println System.out System System.out kotae 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();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	}
} Main
import java.util.Arrays;
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();

		int ans;
		int fod[] = new int[m + 1];
		Arrays.fill(fod, 0);
		int you = 0;

		for (int i = 1; i <= n; i++) {
			you = sc.nextInt();
			for (int s = 1; s <= you; s++) {
				ans = sc.nextInt();
				fod[ans]++;

			}

		}
		
		
		
		int kotae = 0;
		for (int i = 0; i <= m; i++) {
			if (fod[i] == n) {
				kotae++;
			}
		}
		System.out.println(kotae);
	}
}