import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    }

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

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    }

} Main public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    } main {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int ans = 0; ans 0 int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] ary = new int[M]; ary new int[M] M for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	} {
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	} int cnt = sc.nextInt(); cnt sc.nextInt() sc.nextInt sc for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		} int j = 0; int j = 0; j 0 j < cnt j cnt j++ j++ j {
    			ary[sc.nextInt()-1]++;
    		} {
    			ary[sc.nextInt()-1]++;
    		} ary[sc.nextInt()-1]++ ary[sc.nextInt()-1] ary sc.nextInt()-1 sc.nextInt() sc.nextInt sc 1 sc.close() sc.close sc for(int sum : ary){
    		if(sum == N) ans++;
    	} int sum ary {
    		if(sum == N) ans++;
    	} {
    		if(sum == N) ans++;
    	} if(sum == N) ans++; sum == N sum N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    }

} Main
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {

//    	File file = new File("test.txt");
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);
    	int ans = 0;
    	int N = sc.nextInt();
    	int M = sc.nextInt();
    	int[] ary = new int[M];
    	for(int i = 0; i < N; i++){
    		int cnt = sc.nextInt();
    		for(int j = 0; j < cnt; j++){
    			ary[sc.nextInt()-1]++;
    		}
    	}
    	sc.close();
    	for(int sum : ary){
    		if(sum == N) ans++;
    	}
    	System.out.println(ans);
    }

}
