import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    }
} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    } 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 HashMap<Integer, Integer> map = new HashMap<>(); map new HashMap<>() for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        } int i = 1; int i = 1; i 1 i <= m i m i++ i++ i {
            // 初期化
            map.put(i, 0);
        } {
            // 初期化
            map.put(i, 0);
        } map.put(i, 0) map.put map i 0 for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        } {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        } int count = sc.nextInt(); count sc.nextInt() sc.nextInt sc for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            } int j = 0; int j = 0; j 0 j < count j count j++ j++ j {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            } {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            } int food = sc.nextInt(); food sc.nextInt() sc.nextInt sc map.put(food, map.get(food)+1) map.put map food map.get(food)+1 map.get(food) map.get map food 1 int count = 0; count 0 for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        } Map.Entry entry map.entrySet() map.entrySet map {
            if ((Integer) entry.getValue() == n) count++;
        } {
            if ((Integer) entry.getValue() == n) count++;
        } if ((Integer) entry.getValue() == n) count++; (Integer) entry.getValue() == n (Integer) entry.getValue() entry.getValue entry n 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 sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    }
} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();// 人数
        int m = sc.nextInt();// 種類
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 1; i <= m; i++) {
            // 初期化
            map.put(i, 0);
        }

        for (int i = 0; i < n; i++) {
            int count = sc.nextInt();// 調査した食べ物の数
            for (int j = 0; j < count; j++) {
                int food = sc.nextInt();
                map.put(food, map.get(food)+1);
            }
        }

        int count = 0;
        for (Map.Entry entry: map.entrySet()){
            if ((Integer) entry.getValue() == n) count++;
        }

        System.out.println(count);
    }
}
