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 ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(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 ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(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 ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(i==n)ans++;
      }
      System.out.println(ans);
      
    } main {
    	Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(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 ans = 0; ans 0 int[] count = new int[31]; count new int[31] 31 for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      } {
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      } int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        } int j = 0; int j = 0; j 0 j < num j num j++ j++ j {
        	count[sc.nextInt()]++;
        } {
        	count[sc.nextInt()]++;
        } count[sc.nextInt()]++ count[sc.nextInt()] count sc.nextInt() sc.nextInt sc for(int i:count){
      	if(i==n)ans++;
      } int i count {
      	if(i==n)ans++;
      } {
      	if(i==n)ans++;
      } if(i==n)ans++; i==n i n 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 ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(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 ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(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 ans = 0;
      int[] count = new int[31];
      for(int i = 0;i < n;i++){
      	int num = sc.nextInt();
        for(int j = 0;j < num;j++){
        	count[sc.nextInt()]++;
        }
      }
      for(int i:count){
      	if(i==n)ans++;
      }
      System.out.println(ans);
      
    }
}
