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[] k = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    }
} 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 = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    } main {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    } 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 = new int[n]; k new int[n] n int[] c = new int[m + 1]; c new int[m + 1] m + 1 m 1 for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        } 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++) {
                int d = sc.nextInt();
                c[d]++;
            }
        } {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        } k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            } int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
                int d = sc.nextInt();
                c[d]++;
            } {
                int d = sc.nextInt();
                c[d]++;
            } int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc c[d]++ c[d] c d int ans = 0; ans 0 for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        } int i = 0; int i = 0; i 0 i < c.length i c.length c c.length i++ i++ i {
            if(c[i] == n) ans++;
        } {
            if(c[i] == n) ans++;
        } if(c[i] == n) ans++; c[i] == n c[i] c i n ans++ ans System.out.println(ans) System.out.println System.out System System.out ans 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 = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    }
} 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 = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    }
} 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[] k = new int[n];
        int[] c = new int[m + 1];
        for (int i = 0; i < n; i++) {
            k[i] = sc.nextInt();
            for (int j = 0; j < k[i]; j++) {
                int d = sc.nextInt();
                c[d]++;
            }
        }
        int ans = 0;
        for (int i = 0; i < c.length; i++) {
            if(c[i] == n) ans++;
        }
        System.out.println(ans);
    }
}