import java.util.Scanner;

/**
 * ABC118B
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
} 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();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    } 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 int K = 0; K 0 int A = 0; A 0 int[] food = new int[M]; food new int[M] M for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        } {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        } K = sc.nextInt() K sc.nextInt() sc.nextInt sc for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            } int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
                A = sc.nextInt();
                food[A - 1]++;
            } {
                A = sc.nextInt();
                food[A - 1]++;
            } A = sc.nextInt() A sc.nextInt() sc.nextInt sc food[A - 1]++ food[A - 1] food A - 1 A 1 int ans = 0; ans 0 for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
            if (food[i] == N) {
                ans++;
            }
        } {
            if (food[i] == N) {
                ans++;
            }
        } if (food[i] == N) {
                ans++;
            } food[i] == N food[i] food i N {
                ans++;
            } ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc 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();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
} Main
import java.util.Scanner;

/**
 * ABC118B
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int K = 0;
        int A = 0;
        int[] food = new int[M];
        for (int i = 0; i < N; i++) {
            K = sc.nextInt();
            for (int j = 0; j < K; j++) {
                A = sc.nextInt();
                food[A - 1]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < M; i++) {
            if (food[i] == N) {
                ans++;
            }
        }

        System.out.println(ans);

        sc.close();
    }
}