import java.util.Scanner;

//Scanner sc = new Scanner(System.in);

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	}
} 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[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	} 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[] loves = new int[M]; loves new int[M] M for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		} {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				int A = sc.nextInt();
				loves[A-1]++; 
			} {
				int A = sc.nextInt();
				loves[A-1]++; 
			} int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc loves[A-1]++ loves[A-1] loves A-1 A 1 int total = 0; total 0 for(int x: loves){
		  if(x == N) total++;
		} int x loves {
		  if(x == N) total++;
		} {
		  if(x == N) total++;
		} if(x == N) total++; x == N x N total++ total System.out.println(total) System.out.println System.out System System.out total 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[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	}
} Main
import java.util.Scanner;

//Scanner sc = new Scanner(System.in);

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] loves = new int[M];
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			for(int j = 0; j < K; j++){
				int A = sc.nextInt();
				loves[A-1]++; 
			}
		}
		int total = 0;
		for(int x: loves){
		  if(x == N) total++;
		}
		System.out.println(total);
	}
}
