import java.util.Scanner;

class Problem {
    private int N;
    private int M;
    private int[] As;

    Problem() {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();

        As = new int[M];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        }
    }

    int solve() {
        int ans = 0;
        for (int i = 0; i < M; i++){
            if (As[i] == N){
                ans += 1;
            }
        }
        return ans;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
} import java.util.Scanner; Scanner java.util class Problem {
    private int N;
    private int M;
    private int[] As;

    Problem() {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();

        As = new int[M];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        }
    }

    int solve() {
        int ans = 0;
        for (int i = 0; i < M; i++){
            if (As[i] == N){
                ans += 1;
            }
        }
        return ans;
    }
} Problem private int N; N private int M; M private int[] As; As Problem() {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();

        As = new int[M];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        }
    } Problem {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();

        As = new int[M];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) N = sc.nextInt() N sc.nextInt() sc.nextInt sc M = sc.nextInt() M sc.nextInt() sc.nextInt sc As = new int[M] As new int[M] M for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        } 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++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        } {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        } int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            } int k = 0; int k = 0; k 0 k < K k K k++ k++ k {
                int A = sc.nextInt();
                As[A-1] += 1;
            } {
                int A = sc.nextInt();
                As[A-1] += 1;
            } int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc As[A-1] += 1 As[A-1] As A-1 A 1 1 int solve() {
        int ans = 0;
        for (int i = 0; i < M; i++){
            if (As[i] == N){
                ans += 1;
            }
        }
        return ans;
    } solve {
        int ans = 0;
        for (int i = 0; i < M; i++){
            if (As[i] == N){
                ans += 1;
            }
        }
        return ans;
    } int ans = 0; ans 0 for (int i = 0; i < M; i++){
            if (As[i] == N){
                ans += 1;
            }
        } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
            if (As[i] == N){
                ans += 1;
            }
        } {
            if (As[i] == N){
                ans += 1;
            }
        } if (As[i] == N){
                ans += 1;
            } As[i] == N As[i] As i N {
                ans += 1;
            } ans += 1 ans 1 return ans; ans public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
} Main public static void main(String[] args) {
        System.out.println(new Problem().solve());
    } main {
        System.out.println(new Problem().solve());
    } System.out.println(new Problem().solve()) System.out.println System.out System System.out new Problem().solve() new Problem().solve new Problem() String[] args args public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
} public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
} Main
import java.util.Scanner;

class Problem {
    private int N;
    private int M;
    private int[] As;

    Problem() {
        Scanner sc = new Scanner(System.in);

        N = sc.nextInt();
        M = sc.nextInt();

        As = new int[M];
        for (int i = 0; i < N; i++) {
            int K = sc.nextInt();
            for (int k = 0; k < K; k++) {
                int A = sc.nextInt();
                As[A-1] += 1;
            }
        }
    }

    int solve() {
        int ans = 0;
        for (int i = 0; i < M; i++){
            if (As[i] == N){
                ans += 1;
            }
        }
        return ans;
    }
}

public class Main {
    public static void main(String[] args) {
        System.out.println(new Problem().solve());
    }
}
