import java.util.HashMap;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] k = new int[n];
		
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0;i < n;i++){
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		}
		int ans = 0;
		for(int num:map.values()){
			if(num == n){
				ans++;
			}
		}
		System.out.println(ans);
		
	}
}
 import java.util.HashMap; HashMap java.util import java.util.Scanner; Scanner java.util class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] k = new int[n];
		
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0;i < n;i++){
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		}
		int ans = 0;
		for(int num:map.values()){
			if(num == n){
				ans++;
			}
		}
		System.out.println(ans);
		
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] k = new int[n];
		
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0;i < n;i++){
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		}
		int ans = 0;
		for(int num:map.values()){
			if(num == n){
				ans++;
			}
		}
		System.out.println(ans);
		
	} main {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] k = new int[n];
		
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0;i < n;i++){
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		}
		int ans = 0;
		for(int num:map.values()){
			if(num == n){
				ans++;
			}
		}
		System.out.println(ans);
		
	} 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 HashMap<Integer,Integer> map = new HashMap<Integer,Integer>(); map new HashMap<Integer,Integer>() for(int i = 0;i < n;i++){
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		} 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 num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		} {
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		} k[i] = sc.nextInt() k[i] k i sc.nextInt() sc.nextInt sc for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			} int j = 0; int j = 0; j 0 j < k[i] j k[i] k i j++ j++ j {
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			} {
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc int sum = map.getOrDefault(num, 0); sum map.getOrDefault(num, 0) map.getOrDefault map num 0 map.put(num,sum + 1) map.put map num sum + 1 sum 1 int ans = 0; ans 0 for(int num:map.values()){
			if(num == n){
				ans++;
			}
		} int num map.values() map.values map {
			if(num == n){
				ans++;
			}
		} {
			if(num == n){
				ans++;
			}
		} if(num == n){
				ans++;
			} num == n num n {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args
import java.util.HashMap;
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] k = new int[n];
		
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		
		for(int i = 0;i < n;i++){
			k[i] = sc.nextInt();
			for(int j = 0;j < k[i];j++){
				int num = sc.nextInt();
				int sum = map.getOrDefault(num, 0);
				map.put(num,sum + 1);
			}
		}
		int ans = 0;
		for(int num:map.values()){
			if(num == n){
				ans++;
			}
		}
		System.out.println(ans);
		
	}
}

