import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      
      	int hito = sc.nextInt();
      	int menu = sc.nextInt();
      	int mesi[] = new int[menu+1];
      
      for(int i = 0; i < hito; i++){
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      }
		int cnt = 0;
		for(int i = 1; i <= menu ; i++){
          if(mesi[i]==hito){cnt++;}
        }
      	System.out.print(cnt);


    }
} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      
      	int hito = sc.nextInt();
      	int menu = sc.nextInt();
      	int mesi[] = new int[menu+1];
      
      for(int i = 0; i < hito; i++){
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      }
		int cnt = 0;
		for(int i = 1; i <= menu ; i++){
          if(mesi[i]==hito){cnt++;}
        }
      	System.out.print(cnt);


    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      
      	int hito = sc.nextInt();
      	int menu = sc.nextInt();
      	int mesi[] = new int[menu+1];
      
      for(int i = 0; i < hito; i++){
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      }
		int cnt = 0;
		for(int i = 1; i <= menu ; i++){
          if(mesi[i]==hito){cnt++;}
        }
      	System.out.print(cnt);


    } main {
        Scanner sc = new Scanner(System.in);
      
      	int hito = sc.nextInt();
      	int menu = sc.nextInt();
      	int mesi[] = new int[menu+1];
      
      for(int i = 0; i < hito; i++){
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      }
		int cnt = 0;
		for(int i = 1; i <= menu ; i++){
          if(mesi[i]==hito){cnt++;}
        }
      	System.out.print(cnt);


    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int hito = sc.nextInt(); hito sc.nextInt() sc.nextInt sc int menu = sc.nextInt(); menu sc.nextInt() sc.nextInt sc int mesi[] = new int[menu+1]; mesi new int[menu+1] menu+1 menu 1 for(int i = 0; i < hito; i++){
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      } int i = 0; int i = 0; i 0 i < hito i hito i++ i++ i {
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      } {
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        } int j = 0; int j = 0; j 0 j < a j a j++ j++ j {
        	mesi[sc.nextInt()] += 1;
        } {
        	mesi[sc.nextInt()] += 1;
        } mesi[sc.nextInt()] += 1 mesi[sc.nextInt()] mesi sc.nextInt() sc.nextInt sc 1 int cnt = 0; cnt 0 for(int i = 1; i <= menu ; i++){
          if(mesi[i]==hito){cnt++;}
        } int i = 1; int i = 1; i 1 i <= menu i menu i++ i++ i {
          if(mesi[i]==hito){cnt++;}
        } {
          if(mesi[i]==hito){cnt++;}
        } if(mesi[i]==hito){cnt++;} mesi[i]==hito mesi[i] mesi i hito {cnt++;} cnt++ cnt System.out.print(cnt) System.out.print System.out System System.out cnt String[] args args
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      
      	int hito = sc.nextInt();
      	int menu = sc.nextInt();
      	int mesi[] = new int[menu+1];
      
      for(int i = 0; i < hito; i++){
        int a = sc.nextInt();
      	for(int j = 0; j < a;j++){
        	mesi[sc.nextInt()] += 1;
        }
      }
		int cnt = 0;
		for(int i = 1; i <= menu ; i++){
          if(mesi[i]==hito){cnt++;}
        }
      	System.out.print(cnt);


    }
}