import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    } main {
        Scanner scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        } {
            scan.close();
        } scan.close() scan.close scan {
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        } int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int M = scan.nextInt()+1; M scan.nextInt()+1 scan.nextInt() scan.nextInt scan 1 int[][] A_ = new int[N][M]; A_ new int[N][M] N M int[] Kind_ = new int[M]; Kind_ new int[M] M for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            } {
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            } for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                } int j = 0; int j = 0; j 0 j < M j M j++ j++ j {
                    A_[i][j] = 0;
                } {
                    A_[i][j] = 0;
                } A_[i][j] = 0 A_[i][j] A_[i] A_ i j 0 for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
                Kind_[i] = 0;
            } {
                Kind_[i] = 0;
            } Kind_[i] = 0 Kind_[i] Kind_ i 0 for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            } {
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            } int K = scan.nextInt(); K scan.nextInt() scan.nextInt scan for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                } {
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                } A_[i][j] = scan.nextInt() A_[i][j] A_[i] A_ i j scan.nextInt() scan.nextInt scan Kind_[A_[i][j]]++ Kind_[A_[i][j]] Kind_ A_[i][j] A_[i] A_ i j int count = 0; count 0 for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            } int i = 1; int i = 1; i 1 i < M i M i++ i++ i {
                if(Kind_[i] == N){
                    count++;
                }
            } {
                if(Kind_[i] == N){
                    count++;
                }
            } if(Kind_[i] == N){
                    count++;
                } Kind_[i] == N Kind_[i] Kind_ 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 scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    }
} public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        try{
            int N = scan.nextInt();
            int M = scan.nextInt()+1;
            int[][] A_ = new int[N][M];
            int[] Kind_ = new int[M];

            //初期化
            for(int i = 0; i < N; i++){
                for(int j = 0; j < M; j++){
                    A_[i][j] = 0;
                }
            }
            for(int i = 0; i < M; i++){
                Kind_[i] = 0;
            }

            //連想配列
            for(int i = 0; i < N; i++){
                int K = scan.nextInt();
                for(int j = 0; j < K; j++){
                    A_[i][j] = scan.nextInt();
                    Kind_[A_[i][j]]++;
                }
            }

            int count = 0;
            for(int i = 1; i < M; i++){
                if(Kind_[i] == N){
                    count++;
                }
            }
            System.out.println(count);
        }finally{
            scan.close();
        }
    }
}
