import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    }

} import java.util.Scanner; Scanner 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[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    } 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[] a = new int[M]; a new int[M] M for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        } 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++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        } {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                int b = sc.nextInt()-1;
                a[b]++;
            } {
                int b = sc.nextInt()-1;
                a[b]++;
            } int b = sc.nextInt()-1; b sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 a[b]++ a[b] a b int ans = 0; ans 0 for(int c:a){
            if(c == N) ans++;
        } int c a {
            if(c == N) ans++;
        } {
            if(c == N) ans++;
        } if(c == N) ans++; c == N c N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc 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[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        for (int i = 0; i < N; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt()-1;
                a[b]++;
            }
        }
        int ans = 0;
        for(int c:a){
            if(c == N) ans++;
        }

        System.out.println(ans);
        sc.close();


    }

}
