import 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[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	}
} import java.util.*; util.* 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[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	}
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
      	
          int[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	} main {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
      	
          int[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	} 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[] food; food food = new int[M] food new int[M] M for(int k=0;k<M;k++) {
      food[k] = 0;
        } int k=0; int k=0; k 0 k<M k M k++ k++ k {
      food[k] = 0;
        } {
      food[k] = 0;
        } food[k] = 0 food[k] food k 0 for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-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 F = sc.nextInt();
          
          food[F-1]++;
          }
		} {
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          } int j=0; int j=0; j 0 j<K j K j++ j++ j {
          int F = sc.nextInt();
          
          food[F-1]++;
          } {
          int F = sc.nextInt();
          
          food[F-1]++;
          } int F = sc.nextInt(); F sc.nextInt() sc.nextInt sc food[F-1]++ food[F-1] food F-1 F 1 int count = 0; count 0 for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	} int w=0; int w=0; w 0 w<M w M w++ w++ w {
    	if(food[w] == N) {
    		count++;
    	}   	
    	} {
    	if(food[w] == N) {
    		count++;
    	}   	
    	} if(food[w] == N) {
    		count++;
    	} food[w] == N food[w] food w N {
    		count++;
    	} count++ count System.out.println(count) System.out.println System.out System System.out count 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[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	}
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
      	
          int[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	}
} Main
import 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[] food;
      food = new int[M];
      
        for(int k=0;k<M;k++) {
      food[k] = 0;
        }
        
    	for(int i=0;i<N;i++){
        int K = sc.nextInt();
        
        for(int j=0;j<K;j++){
          int F = sc.nextInt();
          
          food[F-1]++;
          }
		}
		int count = 0;
		for(int w=0;w<M;w++){
    	if(food[w] == N) {
    		count++;
    	}   	
    	}
		System.out.println(count);
  	}
}