import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    }

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

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    }

} Main private static Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    } main {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    } int N N M; M N = scanner.nextInt() N scanner.nextInt() scanner.nextInt scanner M = scanner.nextInt() M scanner.nextInt() scanner.nextInt scanner Map<Integer, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 0; i <= M; i++) map.put(i, 0); int i = 0; int i = 0; i 0 i <= M i M i++ i++ i map.put(i, 0); map.put(i, 0) map.put map i 0 for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        } int n = 0; int n = 0; n 0 n < N n N n++ n++ n {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        } {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        } int max = scanner.nextInt(); max scanner.nextInt() scanner.nextInt scanner for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            } int i = 0; int i = 0; i 0 i < max i max i++ i++ i {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            } {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            } int value = scanner.nextInt(); value scanner.nextInt() scanner.nextInt scanner map.put(value, map.get(value) + 1) map.put map value map.get(value) + 1 map.get(value) map.get map value 1 int count = 0; count 0 for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0; int i = 0; int i = 0; i 0 i <= M i M i++ i++ i count += map.get(i) == N ? 1 : 0; count += map.get(i) == N ? 1 : 0 count map.get(i) == N ? 1 : 0 map.get(i) == N map.get(i) map.get map i N 1 0 System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    }

} public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    }

} Main
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    private static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N, M;
        N = scanner.nextInt();
        M = scanner.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i <= M; i++) map.put(i, 0);

        for (int n = 0; n < N; n++) {
            int max = scanner.nextInt();

            for (int i = 0; i < max; i++) {
                int value = scanner.nextInt();
                map.put(value, map.get(value) + 1);
            }
        }

        int count = 0;
        for (int i = 0; i <= M; i++) count += map.get(i) == N ? 1 : 0;

        System.out.println(count);
    }

}
