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 [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
} 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 [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    } 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 [][] K = new int [N][M+1]; K new int [N][M+1] N M+1 M 1 int [] count = new int [M]; count new int [M] M int ans = 0; ans 0 for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        } int i=0; int i=0; i 0 i<N i N i++ i++ i {
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        } {
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        } K[i][0] =sc.nextInt() K[i][0] K[i] K i 0 sc.nextInt() sc.nextInt sc for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            } int j=1; int j=1; j 1 j<=K[i][0] j K[i][0] K[i] K i 0 j++ j++ j {
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            } {
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            } K[i][j] = sc.nextInt() K[i][j] K[i] K i j sc.nextInt() sc.nextInt sc count[K[i][j]-1]++ count[K[i][j]-1] count K[i][j]-1 K[i][j] K[i] K i j 1 for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        } int i=0; int i=0; i 0 i<M i M i++ i++ i {
            if(count[i] == N){
                ans++;
            }
        } {
            if(count[i] == N){
                ans++;
            }
        } if(count[i] == N){
                ans++;
            } count[i] == N count[i] count i N {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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 [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
} 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 [][] K = new int [N][M+1];
        int [] count = new int [M];
        int ans = 0;
        
        for(int i=0; i<N; i++){
            K[i][0] =sc.nextInt();
            for(int j=1; j<=K[i][0]; j++){
                K[i][j] = sc.nextInt();
                count[K[i][j]-1]++;
            }
        }
        
        for(int i=0; i<M; i++){
            if(count[i] == N){
                ans++;
            }
        }
        
        System.out.println(ans);
    }
}
