import java.util.Scanner;
public class Main {

	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  }
  
 
    
        
} 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[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  }
  
 
    
        
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  } main {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  } 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[] tabemono = new int[M]; tabemono new int[M] M for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	} int i = 0; int i = 0; i 0 i<N i N i++ i++ i {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	} {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	} int K_i = sc.nextInt(); K_i sc.nextInt() sc.nextInt sc for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		} int p = 0; int p = 0; p 0 p<K_i p K_i p++ p++ p {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		} {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		} int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc tabemono[c-1]++ tabemono[c-1] tabemono c-1 c 1 int counter=0; counter 0 for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	} int r = 0; int r = 0; r 0 r<M r M r++ r++ r {
    		if(tabemono[r]>=N)counter++;
    	} {
    		if(tabemono[r]>=N)counter++;
    	} if(tabemono[r]>=N)counter++; tabemono[r]>=N tabemono[r] tabemono r N counter++ counter System.out.println(counter) System.out.println System.out System System.out counter 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[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  }
  
 
    
        
} public class Main {

	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  }
  
 
    
        
} Main
import java.util.Scanner;
public class Main {

	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] tabemono = new int[M]; 
    	for(int i = 0; i<N; i++) {
    		int K_i = sc.nextInt();
    		for(int p = 0; p<K_i; p++) {
    			int c = sc.nextInt();
    			tabemono[c-1]++;
    		}
    	}
    	int counter=0;
    	for(int r = 0; r<M; r++) {
    		if(tabemono[r]>=N)counter++;
    	}
    	
    	System.out.println(counter);
    	
    	
    	
    	
  }
  
 
    
        
}
