import java.util.*;
//import java.util.stream.Collectors;

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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == n){
				count++;
			}
		}
		System.out.println(count);
	}
} import java.util.*; util.* java 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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == 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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == 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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == 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[] foods = new int[m+1]; foods new int[m+1] m+1 m 1 for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		} int i=0; int i=0; i 0 i<n i n i++ i++ i {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		} {
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		} int 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++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			} int j=0; int j=0; j 0 j<k j k j++ j++ j {
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			} {
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			} int a = Integer.parseInt(sc.next()); a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc foods[a]++ foods[a] foods a int count = 0; count 0 for(int f : foods){
			if(f == n){
				count++;
			}
		} int f foods {
			if(f == n){
				count++;
			}
		} {
			if(f == n){
				count++;
			}
		} if(f == n){
				count++;
			} f == n f 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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == 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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == n){
				count++;
			}
		}
		System.out.println(count);
	}
} Main
import java.util.*;
//import java.util.stream.Collectors;

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[] foods = new int[m+1];
		for(int i=0; i<n; i++){
			int k = Integer.parseInt(sc.next());
			for(int j=0; j<k; j++){
				int a = Integer.parseInt(sc.next());
				foods[a]++;
			}
		}
		int count = 0;
		for(int f : foods){
			if(f == n){
				count++;
			}
		}
		System.out.println(count);
	}
}
