import java.util.Arrays;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    }
} import java.util.Arrays; Arrays java.util public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    }
} Main private static java.util.Scanner scanner = new java.util.Scanner(System.in); scanner new java.util.Scanner(System.in) public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    } main {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    } int n = scanner.nextInt(); n scanner.nextInt() scanner.nextInt scanner int m = scanner.nextInt(); m scanner.nextInt() scanner.nextInt scanner int[] array = new int[m]; array new int[m] m Arrays.fill(array, 0) Arrays.fill Arrays array 0 for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        } {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        } int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++; int i1 = 0; int i1 = 0; i1 0 i1 < k i1 k i1++ i1++ i1 array[scanner.nextInt() - 1]++; array[scanner.nextInt() - 1]++ array[scanner.nextInt() - 1] array scanner.nextInt() - 1 scanner.nextInt() scanner.nextInt scanner 1 int count = 0; count 0 for (int i : array)
            if (i == n)
                count++; int i array if (i == n)
                count++; if (i == n)
                count++; i == n i n count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    }
} public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    }
} Main
import java.util.Arrays;

public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int m = scanner.nextInt();

        int[] array = new int[m];
        Arrays.fill(array, 0);
        for (int i = 0; i < n; i++) {
            int k = scanner.nextInt();
            for (int i1 = 0; i1 < k; i1++)
                array[scanner.nextInt() - 1]++;
        }

        int count = 0;
        for (int i : array)
            if (i == n)
                count++;
        System.out.println(count);
    }
}