import java.util.Scanner;

// B - Foods Loved by Everyone
// https://atcoder.jp/contests/abc118/tasks/abc118_b
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    }
}
 import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    } main {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int N = Integer.parseInt(scanner.next()); N Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int M = Integer.parseInt(scanner.next()); M Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner int[] A = new int[M]; A new int[M] M for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        } int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        } {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        } int count = Integer.parseInt(scanner.next()); count Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            } int j = 0; int j = 0; j 0 j < count j count j++ j++ j {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            } {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            } int index = Integer.parseInt(scanner.next()) - 1; index Integer.parseInt(scanner.next()) - 1 Integer.parseInt(scanner.next()) Integer.parseInt Integer scanner.next() scanner.next scanner 1 A[index]++ A[index] A index scanner.close() scanner.close scanner int sum = 0; sum 0 for (int a : A) {
            if (a == N) sum++;
        } int a A {
            if (a == N) sum++;
        } {
            if (a == N) sum++;
        } if (a == N) sum++; a == N a N sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    }
} public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    }
} Main
import java.util.Scanner;

// B - Foods Loved by Everyone
// https://atcoder.jp/contests/abc118/tasks/abc118_b
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());

        int[] A = new int[M];
        for (int i = 0; i < N; i++) {
            int count = Integer.parseInt(scanner.next());
            for (int j = 0; j < count; j++) {
                int index = Integer.parseInt(scanner.next()) - 1;
                A[index]++;
            }
        }
        scanner.close();

        int sum = 0;
        for (int a : A) {
            if (a == N) sum++;
        }

        System.out.println(sum);
    }
}

