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 f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==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 f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==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 f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==N) result++;
        }
        System.out.println(result);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==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 f[] = new int[M]; f new int[M] M for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        } {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        } int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            } int k=0; int k=0; k 0 k<count k count k++ k++ k {
                int t = sc.nextInt();
                f[t-1]++;
            } {
                int t = sc.nextInt();
                f[t-1]++;
            } int t = sc.nextInt(); t sc.nextInt() sc.nextInt sc f[t-1]++ f[t-1] f t-1 t 1 int result = 0; result 0 for(int t=0; t<M; t++) {
            if(f[t]==N) result++;
        } int t=0; int t=0; t 0 t<M t M t++ t++ t {
            if(f[t]==N) result++;
        } {
            if(f[t]==N) result++;
        } if(f[t]==N) result++; f[t]==N f[t] f t N 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 f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==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 f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==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 f[] = new int[M];
        for(int i=0; i<N; i++) {
            int count = sc.nextInt();
            for(int k=0; k<count; k++) {
                int t = sc.nextInt();
                f[t-1]++;
            }
        }
        int result = 0;
        for(int t=0; t<M; t++) {
            if(f[t]==N) result++;
        }
        System.out.println(result);
    }
}
