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> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    }
} 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> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    }
} Main public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    } main {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        Map<Integer, Integer> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    } 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> map = new HashMap<>(); map new HashMap<>() for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        } int n = 0; int n = 0; n 0 n < N n N n += 1 n += 1 n 1 {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        } {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            } int k = 0; int k = 0; k 0 k < K k K k += 1 k += 1 k 1 {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            } {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            } int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                } !map.containsKey(a) map.containsKey(a) map.containsKey map a {
                    map.put(a, 1);
                } map.put(a, 1) map.put map a 1 {
                    map.put(a, map.get(a) + 1);
                } map.put(a, map.get(a) + 1) map.put map a map.get(a) + 1 map.get(a) map.get map a 1 Set<Integer> keys = map.keySet(); keys map.keySet() map.keySet map int n = 0; n 0 for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        } int a keys {
            if (map.get(a) == N) {
                n += 1;
            }
        } {
            if (map.get(a) == N) {
                n += 1;
            }
        } if (map.get(a) == N) {
                n += 1;
            } map.get(a) == N map.get(a) map.get map a N {
                n += 1;
            } n += 1 n 1 System.out.println(n) System.out.println System.out System System.out n 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> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    }
} 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> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    }
} 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();

        Map<Integer, Integer> map = new HashMap<>();
        for (int n = 0; n < N; n += 1) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k += 1) {
                int a = sc.nextInt();
                if (!map.containsKey(a)) {
                    map.put(a, 1);
                } else {
                    map.put(a, map.get(a) + 1);
                }
            }
        }

        Set<Integer> keys = map.keySet();
        int n = 0;
        for (int a : keys) {
            if (map.get(a) == N) {
                n += 1;
            }
        }
        System.out.println(n);
    }
}
