import java.util.Scanner;

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

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    } main {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = scanner.nextInt(); N scanner.nextInt() scanner.nextInt scanner int M = scanner.nextInt(); M scanner.nextInt() scanner.nextInt scanner int[] cnts= new int[M]; cnts new int[M] M for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        } {
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        } int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            } int j=0; int j=0; j 0 j<k j k j++ j++ j {
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            } {
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            } int idx = scanner.nextInt(); idx scanner.nextInt() scanner.nextInt scanner idx-- idx cnts[idx]++ cnts[idx] cnts idx int cnt = 0; cnt 0 for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        } int i=0; int i=0; i 0 i<M i M i++ i++ i {
            if(cnts[i] == N){
                cnt++;
            }
        } {
            if(cnts[i] == N){
                cnt++;
            }
        } if(cnts[i] == N){
                cnt++;
            } cnts[i] == N cnts[i] cnts i N {
                cnt++;
            } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
} Main
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] cnts= new int[M];

        for(int i=0; i<N; i++){
            int k = scanner.nextInt();
            for(int j=0; j<k; j++){
                int idx = scanner.nextInt();
                idx--;
                cnts[idx]++;
            }
        }

        int cnt = 0;
        for(int i=0; i<M; i++){
            if(cnts[i] == N){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}
