import java.util.*;
import 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 count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==n){
                total++;
            }
        }

        System.out.println(total);
 
	}
} import java.util.*; util.* java import java.math.*; math.* java public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==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 count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==n){
                total++;
            }
        }

        System.out.println(total);
 
	} main {
		Scanner sc = new Scanner(System.in);
		// 整数の入
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==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 count[] = new int[m+1]; count new int[m+1] m+1 m 1 for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[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();
	            count[a] = count[a]+1;
	            
	        }

		} {
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        } int j=0; int j=0; j 0 j<k j k j++ j++ j {
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        } {
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc count[a] = count[a]+1 count[a] count a count[a]+1 count[a] count a 1 int total =0; total 0 for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==n){
                total++;
            }
        } int i=0; int i=0; i 0 i<=m i m i++ i++ i {
            int result = count[i];
            if(result ==n){
                total++;
            }
        } {
            int result = count[i];
            if(result ==n){
                total++;
            }
        } int result = count[i]; result count[i] count i if(result ==n){
                total++;
            } result ==n result n {
                total++;
            } 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 count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==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 count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==n){
                total++;
            }
        }

        System.out.println(total);
 
	}
} Main
import java.util.*;
import 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 count[] = new int[m+1];
		
		for(int i=0;i<n;i++){
		    int k = sc.nextInt();
	        for(int j=0;j<k;j++){
	            int a = sc.nextInt();
	            count[a] = count[a]+1;
	            
	        }

		}
		int total =0;
        for(int i=0;i<=m;i++){
            int result = count[i];
            if(result ==n){
                total++;
            }
        }

        System.out.println(total);
 
	}
}