import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    }

} 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[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    }

} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    } main {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    } 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[] count = new int[m]; count new int[m] m int[][] a = new int[n][m]; a new int[n][m] n m int[] k = new int[n]; k new int[n] n for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        } {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        } k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            } {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            } a[i][j] = sc.nextInt() - 1 a[i][j] a[i] a i j sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 count[a[i][j]]++ count[a[i][j]] count a[i][j] a[i] a i j int like = 0; like 0 for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            if (count[i] == n) {
                like++;
            }
        } {
            if (count[i] == n) {
                like++;
            }
        } if (count[i] == n) {
                like++;
            } count[i] == n count[i] count i n {
                like++;
            } like++ like System.out.println(like) System.out.println System.out System System.out like 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[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    }

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    }

} Main
import java.util.Scanner;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        int[] count = new int[m];
        int[][] a = new int[n][m];

        int[] k = new int[n];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                a[i][j] = sc.nextInt() - 1;
                count[a[i][j]]++;
            }
        }

        int like = 0;
        for (int i = 0; i < m; i++) {
            if (count[i] == n) {
                like++;
            }
        }
        System.out.println(like);
    }

}