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[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    }
} 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[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    } main {

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    } 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[] likeNum = new int[M]; likeNum new int[M] M for (int i=0;i<M;i++){
            likeNum[i] = 0;
        } int i=0; int i=0; i 0 i<M i M i++ i++ i {
            likeNum[i] = 0;
        } {
            likeNum[i] = 0;
        } likeNum[i] = 0 likeNum[i] likeNum i 0 for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        } {
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            } int j=0; int j=0; j 0 j<K j K j++ j++ j {
                likeNum[sc.nextInt() - 1]++;
            } {
                likeNum[sc.nextInt() - 1]++;
            } likeNum[sc.nextInt() - 1]++ likeNum[sc.nextInt() - 1] likeNum sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int result=0; result 0 for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        } int i=0; int i=0; i 0 i<M i M i++ i++ i {
            if(likeNum[i] == N){
                result++;
            }
        } {
            if(likeNum[i] == N){
                result++;
            }
        } if(likeNum[i] == N){
                result++;
            } likeNum[i] == N likeNum[i] likeNum i N {
                result++;
            } result++ result System.out.println(result) System.out.println System.out System System.out result 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[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    }
} 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[] likeNum = new int[M];
        for (int i=0;i<M;i++){
            likeNum[i] = 0;
        }

        for(int i=0;i<N;i++){
            int K = sc.nextInt();
            for(int j=0;j<K;j++){
                likeNum[sc.nextInt() - 1]++;
            }
        }

        int result=0;
        for(int i=0;i<M;i++){
            if(likeNum[i] == N){
                result++;
            }
        }
        System.out.println(result);

    }
}
