import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        }
} import java.util.Scanner; Scanner java.util import java.util.Arrays; Arrays java.util public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        }
} Main public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        } main {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int numN = scan.nextInt(); numN scan.nextInt() scan.nextInt scan int numM = scan.nextInt(); numM scan.nextInt() scan.nextInt scan int[][] Like = new int[numN][numM]; Like new int[numN][numM] numN numM int sum = 0; sum 0 int tmp[] = new int[numM]; tmp new int[numM] numM for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                } int i=0; int i=0; i 0 i<numN i numN i++ i++ i {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                } {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                } int numK = scan.nextInt(); numK scan.nextInt() scan.nextInt scan for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    } int j=0; int j=0; j 0 j<numK j numK j++ j++ j {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    } {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    } Like[i][j] = scan.nextInt() Like[i][j] Like[i] Like i j scan.nextInt() scan.nextInt scan tmp[(Like[i][j]-1)]++ tmp[(Like[i][j]-1)] tmp (Like[i][j]-1) Like[i][j] Like[i] Like i j 1 for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                } int z=0; int z=0; z 0 z<numM z numM z++ z++ z {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                } {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                } if ( tmp[z] >= numN ) {
                        sum++;
                    } tmp[z] >= numN tmp[z] tmp z numN {
                        sum++;
                    } sum++ sum System.out.println( sum ) System.out.println System.out System System.out sum scan.close() scan.close scan String[] args args public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        }
} public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        }
} Main
import java.util.Scanner;
import java.util.Arrays;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);
                int numN = scan.nextInt();
                int numM = scan.nextInt();
                int[][] Like = new int[numN][numM];
                int sum = 0;
                int tmp[] = new int[numM];

                for (int i=0; i<numN; i++) {
                    int numK = scan.nextInt();
                    
                    for ( int j=0; j<numK; j++ ) {
                            Like[i][j] = scan.nextInt();
                            tmp[(Like[i][j]-1)]++;

                    }
                }
                for (int z=0; z<numM; z++) {
                    if ( tmp[z] >= numN ) {
                        sum++;
                    }
                }
                
                System.out.println( sum );
                scan.close();
        }
}
