import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    }
} import java.util.*; util.* java import java.io.*; io.* java public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    }
} Main public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    } main {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    } 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[] foodCount = new int[M]; foodCount new int[M] M for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        } int i = 1; int i = 1; i 1 i <= N i N i++ i++ i {
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        } {
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        } int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            } int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
                foodCount[sc.nextInt() - 1]++;
            } {
                foodCount[sc.nextInt() - 1]++;
            } foodCount[sc.nextInt() - 1]++ foodCount[sc.nextInt() - 1] foodCount sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int howManyFoodAllGuysLike = 0; howManyFoodAllGuysLike 0 for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        } int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        } {
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        } if(foodCount[i] == N) howManyFoodAllGuysLike++; foodCount[i] == N foodCount[i] foodCount i N howManyFoodAllGuysLike++ howManyFoodAllGuysLike System.out.println(howManyFoodAllGuysLike) System.out.println System.out System System.out howManyFoodAllGuysLike String[] args args public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    }
} public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    }
} Main
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        
        int[] foodCount = new int[M];
        for(int i = 1; i <= N; i++){
            int k = sc.nextInt();
            for(int j = 0; j < k; j++){
                foodCount[sc.nextInt() - 1]++;
            }
        }
        
        int howManyFoodAllGuysLike = 0;
        for(int i = 0; i < M; i++){
            if(foodCount[i] == N) howManyFoodAllGuysLike++;
        }
        System.out.println(howManyFoodAllGuysLike);
    }
}
