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;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	}
}

 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;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	}
} Main public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	} main {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N; N N = sc.nextInt() N sc.nextInt() sc.nextInt sc int M; M M = sc.nextInt() M sc.nextInt() sc.nextInt sc long[] A=new long[M]; A new long[M] M long ans=0; ans 0 for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	} {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	} int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			} int j = 0; int j = 0; j 0 j < x j x j++ j++ j {
				int X = sc.nextInt();
			A[X-1]++;
			} {
				int X = sc.nextInt();
			A[X-1]++;
			} int X = sc.nextInt(); X sc.nextInt() sc.nextInt sc A[X-1]++ A[X-1] A X-1 X 1 for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
		if(A[i]==N)ans++;
	} {
		if(A[i]==N)ans++;
	} if(A[i]==N)ans++; A[i]==N A[i] A i N ans++ ans System.out.print(ans) System.out.print 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;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	}
} public class Main{

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	}
} 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;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	}
}


