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