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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    }

} import java.util.ArrayList; ArrayList java.util import java.util.List; List 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 = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    } 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 List<Integer> k = new ArrayList<>(); k new ArrayList<>() List<List<Integer>> a = new ArrayList<>(); a new ArrayList<>() for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        } {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        } k.add(sc.nextInt()) k.add k sc.nextInt() sc.nextInt sc List<Integer> list = new ArrayList<>(); list new ArrayList<>() for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            } int j = 0; int j = 0; j 0 j < k.get(i) j k.get(i) k.get k i j++ j++ j {
                list.add(sc.nextInt());
            } {
                list.add(sc.nextInt());
            } list.add(sc.nextInt()) list.add list sc.nextInt() sc.nextInt sc a.add(list) a.add a list List<Integer> correct = new ArrayList<>(a.get(0)); correct new ArrayList<>(a.get(0)) for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        } int i = 1; int i = 1; i 1 i < n i n i++ i++ i {
            correct.retainAll(a.get(i));
        } {
            correct.retainAll(a.get(i));
        } correct.retainAll(a.get(i)) correct.retainAll correct a.get(i) a.get a i System.out.println(correct.size()) System.out.println System.out System System.out correct.size() correct.size correct 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();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    }

} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    }

} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> k = new ArrayList<>();
        List<List<Integer>> a = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            k.add(sc.nextInt());
            List<Integer> list = new ArrayList<>();
            for (int j = 0; j < k.get(i); j++) {
                list.add(sc.nextInt());
            }
            a.add(list);
        }

        List<Integer> correct = new ArrayList<>(a.get(0));
        for (int i = 1; i < n; i++) {
            correct.retainAll(a.get(i));
        }
        System.out.println(correct.size());
    }

}
