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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }
}

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

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

    } main {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int numOfPeople = sc.nextInt(); numOfPeople sc.nextInt() sc.nextInt sc int numOfFoodTypes = sc.nextInt(); numOfFoodTypes sc.nextInt() sc.nextInt sc Map<Integer, Integer> map = new HashMap<>(); map new HashMap<>() int numOfResponses = 0; numOfResponses 0 int cnt = 0; cnt 0 for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        } int i = 0; int i = 0; i 0 i < numOfPeople i numOfPeople i++ i++ i {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        } {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        } numOfResponses = sc.nextInt() numOfResponses sc.nextInt() sc.nextInt sc for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            } int j = 0; int j = 0; j 0 j < numOfResponses j numOfResponses j++ j++ j {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            } {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            } int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc map.put(A, map.getOrDefault(A, 0) + 1) map.put map A map.getOrDefault(A, 0) + 1 map.getOrDefault(A, 0) map.getOrDefault map A 0 1 for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        } int i = 1; int i = 1; i 1 i <= numOfFoodTypes i numOfFoodTypes i++ i++ i {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        } {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        } if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            } map.containsKey(i) && map.get(i) == numOfPeople map.containsKey(i) map.containsKey map i map.get(i) == numOfPeople map.get(i) map.get map i numOfPeople {
                cnt++;
            } cnt++ cnt 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) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }
} public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

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

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int numOfPeople = sc.nextInt();
        int numOfFoodTypes = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        int numOfResponses = 0;
        int cnt = 0;

        for (int i = 0; i < numOfPeople; i++) {
            numOfResponses = sc.nextInt();
            for (int j = 0; j < numOfResponses; j++) {
                int A = sc.nextInt();
                map.put(A, map.getOrDefault(A, 0) + 1);
            }
        }

        for (int i = 1; i <= numOfFoodTypes; i++) {
            if (map.containsKey(i) && map.get(i) == numOfPeople) {
                cnt++;
            }
        }

        System.out.println(cnt);

    }
}


