import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] d = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            k[i] = sc.nextInt();
            for (int j = 0 ; j < k[i] ; j++) {
                int f = sc.nextInt() - 1;
                d[i][f]++;
            }
        }
        int count = 0;
        for (int i = 0 ; i < m ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++) {
                if (d[j][i] == 1) temp++;
            }
            if (temp == n) count++;
        }
        System.out.println(count);
    }

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

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] d = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            k[i] = sc.nextInt();
            for (int j = 0 ; j < k[i] ; j++) {
                int f = sc.nextInt() - 1;
                d[i][f]++;
            }
        }
        int count = 0;
        for (int i = 0 ; i < m ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++) {
                if (d[j][i] == 1) temp++;
            }
            if (temp == n) count++;
        }
        System.out.println(count);
    }

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

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] d = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            k[i] = sc.nextInt();
            for (int j = 0 ; j < k[i] ; j++) {
                int f = sc.nextInt() - 1;
                d[i][f]++;
            }
        }
        int count = 0;
        for (int i = 0 ; i < m ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++) {
                if (d[j][i] == 1) temp++;
            }
            if (temp == n) count++;
        }
        System.out.println(count);
    }

} public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] d = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            k[i] = sc.nextInt();
            for (int j = 0 ; j < k[i] ; j++) {
                int f = sc.nextInt() - 1;
                d[i][f]++;
            }
        }
        int count = 0;
        for (int i = 0 ; i < m ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++) {
                if (d[j][i] == 1) temp++;
            }
            if (temp == n) count++;
        }
        System.out.println(count);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] k = new int[n];
        int[][] d = new int[n][m];
        for (int i = 0 ; i < n ; i++) {
            k[i] = sc.nextInt();
            for (int j = 0 ; j < k[i] ; j++) {
                int f = sc.nextInt() - 1;
                d[i][f]++;
            }
        }
        int count = 0;
        for (int i = 0 ; i < m ; i++) {
            int temp = 0;
            for (int j = 0 ; j < n ; j++) {
                if (d[j][i] == 1) temp++;
            }
            if (temp == n) count++;
        }
        System.out.println(count);
    }

}
