import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    } 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[] marray = new int[m]; marray new int[m] m for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        } {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        } int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            } int j = 0; int j = 0; j 0 j < num j num j++ j++ j {
                int work = sc.nextInt();
                marray[work - 1]++;
            } {
                int work = sc.nextInt();
                marray[work - 1]++;
            } int work = sc.nextInt(); work sc.nextInt() sc.nextInt sc marray[work - 1]++ marray[work - 1] marray work - 1 work 1 int cnt = 0; cnt 0 for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        } int a marray {
            if (a == n) {
                cnt++;
            }
        } {
            if (a == n) {
                cnt++;
            }
        } if (a == n) {
                cnt++;
            } a == n a n {
                cnt++;
            } cnt++ cnt sc.close() sc.close sc System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] marray = new int[m];

        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            for (int j = 0; j < num; j++) {
                int work = sc.nextInt();
                marray[work - 1]++;
            }
        }

        int cnt = 0;

        for (int a : marray) {
            if (a == n) {
                cnt++;
            }
        }
        sc.close();
        System.out.println(cnt);
    }
}
