import java.util.Scanner;


public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
} Main static int N N M M K; K static int[] foods; foods public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	} main {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc M = sc.nextInt() M sc.nextInt() sc.nextInt sc foods = new int[M] foods new int[M] M for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

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

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 } {
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 } K = sc.nextInt() K sc.nextInt() sc.nextInt sc for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 } int j = 0 ; int j = 0 ; j 0 j < K j K j++ j++ j {
				 foods[sc.nextInt()-1] += 1;
			 } {
				 foods[sc.nextInt()-1] += 1;
			 } foods[sc.nextInt()-1] += 1 foods[sc.nextInt()-1] foods sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 1 sc.close() sc.close sc int ans = 0 ; ans 0 for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		} int k = 0 ; int k = 0 ; k 0 k < M k M k++ k++ k {
			if(foods[k] == N){
				ans += 1;
			}
		} {
			if(foods[k] == N){
				ans += 1;
			}
		} if(foods[k] == N){
				ans += 1;
			} foods[k] == N foods[k] foods k N {
				ans += 1;
			} ans += 1 ans 1 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;


public class Main {
	static int N,M,K;
	static int[] foods;
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		 N = sc.nextInt();
		 M = sc.nextInt();
		 foods = new int[M];

		 for(int i = 0 ; i < N ; i++){
			 K = sc.nextInt();

			 for(int j = 0 ; j < K ; j++){
				 foods[sc.nextInt()-1] += 1;
			 }
		 }

		sc.close();

		int ans = 0 ;
		for(int k = 0 ; k < M ; k++){
			if(foods[k] == N){
				ans += 1;
			}
		}
		System.out.println(ans);
	}
}
