import java.util.Scanner;

public class Main{

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    }
} import java.util.Scanner; Scanner java.util public class Main{

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    } main {
        Scanner scan = new Scanner(System.in);

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int people = scan.nextInt(); people scan.nextInt() scan.nextInt scan final int FOODS = scan.nextInt(); FOODS scan.nextInt() scan.nextInt scan int[] value = new int[FOODS]; value new int[FOODS] FOODS for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        } int i = 0; int i = 0; i 0 i < people i people i++ i++ i {
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        } {
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        } int temp = scan.nextInt(); temp scan.nextInt() scan.nextInt scan for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            } int j = 0; int j = 0; j 0 j < temp j temp j++ j++ j {
                value[scan.nextInt() - 1] += 1;
            } {
                value[scan.nextInt() - 1] += 1;
            } value[scan.nextInt() - 1] += 1 value[scan.nextInt() - 1] value scan.nextInt() - 1 scan.nextInt() scan.nextInt scan 1 1 int count = 0; count 0 for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        } int i = 0; int i = 0; i 0 i < FOODS i FOODS i++ i++ i {
            if(value[i] == people){
                count++;
            }
        } {
            if(value[i] == people){
                count++;
            }
        } if(value[i] == people){
                count++;
            } value[i] == people value[i] value i people {
                count++;
            } count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main{

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    }
} public class Main{

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    }
} Main
import java.util.Scanner;

public class Main{

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

        // input
        int people = scan.nextInt();
        final int FOODS = scan.nextInt();
        int[] value = new int[FOODS];
        for(int i = 0; i < people; i++){
            int temp = scan.nextInt();
            for(int j = 0; j < temp; j++){
                value[scan.nextInt() - 1] += 1;
            }
        }

        // search
        int count = 0;
        for(int i = 0; i < FOODS; i++){
            if(value[i] == people){
                count++;
            }
        }

        // answer
        System.out.println(count);

    }
}