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 K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    }
} 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 K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    }
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
  	    int m = sc.nextInt();
        int K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    } main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
  	    int m = sc.nextInt();
        int K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    } 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 K[] = new int[n]; K new int[n] n int A[][] = new int[n][m]; A new int[n][m] n m int fav[] = new int[m]; fav new int[m] m int ans = 0; ans 0 for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        } int i=0; int i=0; i 0 i<n i n i++ i++ i {
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        } {
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        } K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    } int j=0; int j=0; j 0 j<K[i] j K[i] K i j++ j++ j {
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    } {
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    } A[i][j] = sc.nextInt() A[i][j] A[i] A i j sc.nextInt() sc.nextInt sc fav[A[i][j]-1] += 1 fav[A[i][j]-1] fav A[i][j]-1 A[i][j] A[i] A i j 1 1 for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        } int i=0; int i=0; i 0 i<m i m i++ i++ i {
            if(fav[i] == n){
                ans++;
            }
        } {
            if(fav[i] == n){
                ans++;
            }
        } if(fav[i] == n){
                ans++;
            } fav[i] == n fav[i] fav i n {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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 K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
  	    int m = sc.nextInt();
        int K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    }
} 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 K[] = new int[n];
      	int A[][] = new int[n][m]; 
      	int fav[] = new int[m];
      	int ans = 0;
        
        for(int i=0; i<n; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i] ; j++){
                A[i][j] = sc.nextInt();
			    fav[A[i][j]-1] += 1;
     	    }
        }
      	
      	for(int i=0; i<m; i++){
            if(fav[i] == n){
                ans++;
            }
        }
       	
       	System.out.println(ans);
    }
}