import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    }
} Main public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    } main {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] love = new int[m]; love new int[m] m int k k a; a for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        } int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        } {
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        } k = Integer.parseInt(sc.next()) k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            } {
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            } a = Integer.parseInt(sc.next()) a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc love[a-1]++ love[a-1] love a-1 a 1 int count = 0; count 0 for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        } int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
            if(love[i] == n){
                count++;
            }
        } {
            if(love[i] == n){
                count++;
            }
        } if(love[i] == n){
                count++;
            } love[i] == n love[i] love i n {
                count++;
            } 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) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    }
} public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    }
} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] love = new int[m];
        int k, a;
        for(int i = 0; i < n; i++){
            k = Integer.parseInt(sc.next());
            for(int j = 0; j < k; j++){
                a = Integer.parseInt(sc.next());
                love[a-1]++;
            }
        }
        
        int count = 0;
        for(int i = 0; i < m; i++){
            if(love[i] == n){
                count++;
            }
        }
        
        System.out.println(count);
    }
}