import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	}
} import java.util.*; util.* java import static java.lang.Math.*; import static java.lang.Math.*; import static java.lang.Math.*; import java.math.BigInteger; BigInteger java.math public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	} main {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	} 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[] like = new int[m]; like 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() - 1;
		        like[a]++;
		    }
		} 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() - 1;
		        like[a]++;
		    }
		} {
		    int k = sc.nextInt();
		    for(int j = 0; j < k; j++){
		        int a = sc.nextInt() - 1;
		        like[a]++;
		    }
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; j++){
		        int a = sc.nextInt() - 1;
		        like[a]++;
		    } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
		        int a = sc.nextInt() - 1;
		        like[a]++;
		    } {
		        int a = sc.nextInt() - 1;
		        like[a]++;
		    } int a = sc.nextInt() - 1; a sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 like[a]++ like[a] like a int result = 0; result 0 for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
		    if(like[i] == n) result++;
		} {
		    if(like[i] == n) result++;
		} if(like[i] == n) result++; like[i] == n like[i] like i n result++ result System.out.println(result) System.out.println System.out System System.out result 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[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	}
} public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	}
} Main
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
    
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] like = 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() - 1;
		        like[a]++;
		    }
		}

		// 計算
		int result = 0;
		for(int i = 0; i < m; i++){
		    if(like[i] == n) result++;
		}
		
		// 出力
		System.out.println(result);
        
	}
}
