import java.util.Scanner;
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();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} import java.util.Scanner; Scanner java.util 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();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    } 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 Map<Integer, Integer> a = new HashMap<>(); a new HashMap<>() for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        } {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            } {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            } int x = sc.nextInt(); x sc.nextInt() sc.nextInt sc if (!a.containsKey(x)) {
                    a.put(x, 0);
                } !a.containsKey(x) a.containsKey(x) a.containsKey a x {
                    a.put(x, 0);
                } a.put(x, 0) a.put a x 0 a.put(x, a.get(x) + 1) a.put a x a.get(x) + 1 a.get(x) a.get a x 1 int ans = 0; ans 0 for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        } Integer key a.keySet() a.keySet a {
            if (a.get(key) == n) {
                ans++;
            }
        } {
            if (a.get(key) == n) {
                ans++;
            }
        } if (a.get(key) == n) {
                ans++;
            } a.get(key) == n a.get(key) a.get a key n {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }
} Main
import java.util.Scanner;
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();
        Map<Integer, Integer> a = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int x = sc.nextInt();
                if (!a.containsKey(x)) {
                    a.put(x, 0);
                }
                a.put(x, a.get(x) + 1);
            }
        }
        int ans = 0;
        for (Integer key : a.keySet()) {
            if (a.get(key) == n) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}
