import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
	public static void main(String[] args) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        }
      	
      
      	System.out.println(count);
      	
        
	}
} import java.util.*; util.* java import java.text.ParseException; ParseException java.text import java.text.SimpleDateFormat; SimpleDateFormat java.text public class Main {
	public static void main(String[] args) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        }
      	
      
      	System.out.println(count);
      	
        
	}
} Main public static void main(String[] args) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        }
      	
      
      	System.out.println(count);
      	
        
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == 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 key[] = new int[m]; key new int[m] m int key_b[] = new int[m]; key_b new int[m] m int stack; stack int count = 0; count 0 int k; k for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
          key[i] = 0;
          key_b[i] = 0;
        } {
          key[i] = 0;
          key_b[i] = 0;
        } key[i] = 0 key[i] key i 0 key_b[i] = 0 key_b[i] key_b i 0 for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        } {
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        } k = sc.nextInt() k sc.nextInt() sc.nextInt sc for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
          		key_b[sc.nextInt()-1]++;           		             	
          	} {
          		key_b[sc.nextInt()-1]++;           		             	
          	} key_b[sc.nextInt()-1]++ key_b[sc.nextInt()-1] key_b sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
        	if(key_b[i] == n) count++;
        } {
        	if(key_b[i] == n) count++;
        } if(key_b[i] == n) count++; key_b[i] == n key_b[i] key_b i n 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) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        }
      	
      
      	System.out.println(count);
      	
        
	}
} public class Main {
	public static void main(String[] args) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        }
      	
      
      	System.out.println(count);
      	
        
	}
} Main
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;

public class Main {
	public static void main(String[] args) throws ParseException{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
      	int m = sc.nextInt();
      	int key[] = new int[m];
      	int key_b[] = new int[m];
      	int stack;
      	int count = 0;
      	int k;
      	
      
      	for(int i = 0; i < m;i++) {
          key[i] = 0;
          key_b[i] = 0;
        }
      
      
     
      	for(int i = 0; i < n;i++){
          	k = sc.nextInt();
      		for(int j = 0; j < k;j++){
          		key_b[sc.nextInt()-1]++;           		             	
          	}
        }
      
      	for(int i = 0; i < m;i++){
        	if(key_b[i] == n) count++;
        }
      	
      
      	System.out.println(count);
      	
        
	}
}