import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    }

    public static void solver(int N, int M, boolean[][] likeFoods) {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    }
} import java.util.*; util.* java import static java.lang.System.*; import static java.lang.System.*; import static java.lang.System.*; public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    }

    public static void solver(int N, int M, boolean[][] likeFoods) {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    } 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[][] likeFoods = new boolean[N][M+1]; likeFoods new boolean[N][M+1] N M+1 M 1 for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        } {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            } int k = 0; int k = 0; k 0 k < K k K k++ k++ k {
               likeFoods[i][sc.nextInt()] = true;
            } {
               likeFoods[i][sc.nextInt()] = true;
            } likeFoods[i][sc.nextInt()] = true likeFoods[i][sc.nextInt()] likeFoods[i] likeFoods i sc.nextInt() sc.nextInt sc true solver(N, M, likeFoods) solver N M likeFoods String[] args args public static void solver(int N, int M, boolean[][] likeFoods) {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    } solver {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    } int count = 0; count 0 for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        } int m = 1; int m = 1; m 1 m < M+1 m M+1 M 1 m++ m++ m {
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        } {
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        } boolean allLike = true; allLike true for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            } int n = 0; int n = 0; n 0 n < N n N n++ n++ n {
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            } {
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            } if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                } !likeFoods[n][m] likeFoods[n][m] likeFoods[n] likeFoods n m {
                    allLike = false;
                    break;
                } allLike = false allLike false break; if(allLike == true){
                count++;
            } allLike == true allLike true {
                count++;
            } count++ count out.println(count) out.println out count int N N int M M boolean[][] likeFoods likeFoods public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    }

    public static void solver(int N, int M, boolean[][] likeFoods) {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    }

    public static void solver(int N, int M, boolean[][] likeFoods) {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    }
} Main
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        boolean[][] likeFoods = new boolean[N][M+1];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for(int k = 0; k < K; k++){
               likeFoods[i][sc.nextInt()] = true;
            }
        }

        solver(N, M, likeFoods);
    }

    public static void solver(int N, int M, boolean[][] likeFoods) {
        int count = 0;
        for(int m = 1; m < M+1; m++){
            boolean allLike = true;
            for(int n = 0; n < N; n++){
                if(!likeFoods[n][m]){
                    allLike = false;
                    break;
                }
            }
            if(allLike == true){
                count++;
            }
        }
        out.println(count);
    }
}