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[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      }
      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[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      }
      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[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      }
      System.out.println(count);
    } main {
       Scanner sc = new Scanner(System.in);   
       //取得
      int N = sc.nextInt();
      int m = sc.nextInt();
      int[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[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[] M = new int[30]; M new int[30] 30 for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      } int i=0; int i=0; i 0 i<N i N i++ i++ i {
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      } {
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc int[] A = new int[K]; A new int[K] K for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        } int j=0; int j=0; j 0 j<K j K j++ j++ j {
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        } {
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        } A[j] = sc.nextInt() A[j] A j sc.nextInt() sc.nextInt sc M[A[j]-1]++ M[A[j]-1] M A[j]-1 A[j] A j 1 int count=0; count 0 for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      } int i=0; int i=0; i 0 i<30 i 30 i++ i++ i {
        if(M[i]==N){
          count++;
        }
      } {
        if(M[i]==N){
          count++;
        }
      } if(M[i]==N){
          count++;
        } M[i]==N M[i] M i N {
          count++;
        } 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){
       Scanner sc = new Scanner(System.in);   
       //取得
      int N = sc.nextInt();
      int m = sc.nextInt();
      int[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      }
      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[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      }
      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[] M = new int[30];
      for(int i=0;i<N;i++){
        int K = sc.nextInt();
        int[] A = new int[K];
        for(int j=0;j<K;j++){
          A[j] = sc.nextInt();
          M[A[j]-1]++;
        }
      }
      int count=0;
      for(int i=0;i<30;i++){
        if(M[i]==N){
          count++;
        }
      }
      System.out.println(count);
    }
}