import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private Set<Integer> createSet(int M) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i <= M; i++) {
            set.add(i);
        }
        return set;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[] ok = new boolean[M + 1];
        Arrays.fill(ok, true);

        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        }

        System.out.println(cnt);

        return;
    }

} import java.util.*; util.* java class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
} Main public static void main(String[] args) {
        new Solver().run();
    } main {
        new Solver().run();
    } new Solver().run() new Solver().run new Solver() String[] args args class Solver {

    private Set<Integer> createSet(int M) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i <= M; i++) {
            set.add(i);
        }
        return set;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[] ok = new boolean[M + 1];
        Arrays.fill(ok, true);

        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        }

        System.out.println(cnt);

        return;
    }

} Solver private Set<Integer> createSet(int M) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i <= M; i++) {
            set.add(i);
        }
        return set;
    } createSet {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i <= M; i++) {
            set.add(i);
        }
        return set;
    } Set<Integer> set = new HashSet<Integer>(); set new HashSet<Integer>() for (int i = 1; i <= M; i++) {
            set.add(i);
        } int i = 1; int i = 1; i 1 i <= M i M i++ i++ i {
            set.add(i);
        } {
            set.add(i);
        } set.add(i) set.add set i return set; set int M M public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[] ok = new boolean[M + 1];
        Arrays.fill(ok, true);

        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        }

        System.out.println(cnt);

        return;
    } run {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[] ok = new boolean[M + 1];
        Arrays.fill(ok, true);

        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        }

        System.out.println(cnt);

        return;
    } 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 boolean[] ok = new boolean[M + 1]; ok new boolean[M + 1] M + 1 M 1 Arrays.fill(ok, true) Arrays.fill Arrays ok true for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        } {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc Set<Integer> dislike = createSet(M); dislike createSet(M) createSet M for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            } {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            } int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc if (dislike.contains(A)) {
                    dislike.remove(A);
                } dislike.contains(A) dislike.contains dislike A {
                    dislike.remove(A);
                } dislike.remove(A) dislike.remove dislike A for (int A : dislike) {
                ok[A] = false;
            } int A dislike {
                ok[A] = false;
            } {
                ok[A] = false;
            } ok[A] = false ok[A] ok A false int cnt = 0; cnt 0 for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        } int i = 1; int i = 1; i 1 i <= M i M i++ i++ i {
            if (ok[i]) {
                cnt++;
            }
        } {
            if (ok[i]) {
                cnt++;
            }
        } if (ok[i]) {
                cnt++;
            } ok[i] ok i {
                cnt++;
            } cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt return;
import java.util.*;

class Main {
    public static void main(String[] args) {
        new Solver().run();
    }
}

class Solver {

    private Set<Integer> createSet(int M) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i = 1; i <= M; i++) {
            set.add(i);
        }
        return set;
    }

    public void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[] ok = new boolean[M + 1];
        Arrays.fill(ok, true);

        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            Set<Integer> dislike = createSet(M);
            for (int j = 0; j < K; j++) {
                int A = sc.nextInt();
                if (dislike.contains(A)) {
                    dislike.remove(A);
                }
            }
            for (int A : dislike) {
                ok[A] = false;
            }
        }


        int cnt = 0;
        for (int i = 1; i <= M; i++) {
            if (ok[i]) {
                cnt++;
            }
        }

        System.out.println(cnt);

        return;
    }

}