import java.util.Arrays;
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[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    }
} import java.util.Arrays; Arrays java.util 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[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    } 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[] ans = new int[m]; ans new int[m] m Arrays.fill(ans, 0) Arrays.fill Arrays ans 0 for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        } {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                int b = sc.nextInt();
                ans[b - 1]++;
            } {
                int b = sc.nextInt();
                ans[b - 1]++;
            } int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc ans[b - 1]++ ans[b - 1] ans b - 1 b 1 int answe = 0; answe 0 for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            if (ans[i] == n) {
                answe++;
            }
        } {
            if (ans[i] == n) {
                answe++;
            }
        } if (ans[i] == n) {
                answe++;
            } ans[i] == n ans[i] ans i n {
                answe++;
            } answe++ answe System.out.println(answe) System.out.println System.out System System.out answe 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[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    }
} Main
import java.util.Arrays;
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[] ans = new int[m];
        Arrays.fill(ans, 0);
        for (int i = 0; i < n; i++) {
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int b = sc.nextInt();
                ans[b - 1]++;
            }
        }
        int answe = 0;
        for (int i = 0; i < m; i++) {
            if (ans[i] == n) {
                answe++;
            }
        }
        System.out.println(answe);

    }
}