import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    }
} import java.util.ArrayList; ArrayList 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 n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    }
} Main public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    } main {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer[] k = new Integer[n]; k new Integer[n] n ArrayList<Integer[]> aList = new ArrayList<>(); aList new ArrayList<>() for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        } {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        } k[i] = Integer.parseInt(sc.next()) k[i] k i Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc Integer[] a = new Integer[k[i]]; a new Integer[k[i]] k[i] k i for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                a[j] = Integer.parseInt(sc.next());
            } {
                a[j] = Integer.parseInt(sc.next());
            } a[j] = Integer.parseInt(sc.next()) a[j] a j Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc aList.add(a) aList.add aList a Integer[] count = new Integer[m]; count new Integer[m] m for (int i = 0; i < m; i++) {
            count[i] = 0;
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            count[i] = 0;
        } {
            count[i] = 0;
        } count[i] = 0 count[i] count i 0 for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        } {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        } for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                count[aList.get(i)[j] - 1]++;
            } {
                count[aList.get(i)[j] - 1]++;
            } count[aList.get(i)[j] - 1]++ count[aList.get(i)[j] - 1] count aList.get(i)[j] - 1 aList.get(i)[j] aList.get(i) aList.get aList i j 1 int result = 0; result 0 for (int c : count) {
            if (c == n) {
                result++;
            }
        } int c count {
            if (c == n) {
                result++;
            }
        } {
            if (c == n) {
                result++;
            }
        } if (c == n) {
                result++;
            } c == n c n {
                result++;
            } result++ result System.out.println(result) System.out.println System.out System System.out result String args[] args public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

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

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Integer[] k = new Integer[n];
        ArrayList<Integer[]> aList = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k[i] = Integer.parseInt(sc.next());
            Integer[] a = new Integer[k[i]];
            for (int j = 0; j < k[i]; j++) {
                a[j] = Integer.parseInt(sc.next());
            }
            aList.add(a);

        }

        Integer[] count = new Integer[m];
        for (int i = 0; i < m; i++) {
            count[i] = 0;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < k[i]; j++) {
                count[aList.get(i)[j] - 1]++;
            }
        }

        int result = 0;
        for (int c : count) {
            if (c == n) {
                result++;
            }
        }

        System.out.println(result);
    }
}