import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    }
} Main public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    } main {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    } try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        } {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        } Scanner in = new Scanner(System.in) Scanner in = new Scanner(System.in) new Scanner(System.in) int N = in.nextInt(); N in.nextInt() in.nextInt in int M = in.nextInt(); M in.nextInt() in.nextInt in int likeAll = ((1 << M) - 1); likeAll ((1 << M) - 1) (1 << M) 1 M 1 for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            } {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            } int K = in.nextInt(); K in.nextInt() in.nextInt in int like = 0; like 0 for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                } {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                } int A = in.nextInt() - 1; A in.nextInt() - 1 in.nextInt() in.nextInt in 1 like |= (1 << A) like (1 << A) 1 A likeAll &= like likeAll like System.out.println(Integer.bitCount(likeAll)) System.out.println System.out System System.out Integer.bitCount(likeAll) Integer.bitCount Integer likeAll String args[] args public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    }
} public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    }
}
