import 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[] kinds = new int[m];

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

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

} import java.util.*; util.* java public class Main {

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

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

        int[] kinds = new int[m];

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

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

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

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

        int[] kinds = new int[m];

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

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

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

        int[] kinds = new int[m];

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

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

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

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

} public class Main {

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

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

        int[] kinds = new int[m];

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

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

} Main
import 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[] kinds = new int[m];

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

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

}