import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	} main {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int N = sc.nextInt(); N sc.nextInt() sc.nextInt sc int M = Integer.parseInt(sc.nextLine().trim()); M Integer.parseInt(sc.nextLine().trim()) Integer.parseInt Integer sc.nextLine().trim() sc.nextLine().trim sc.nextLine() sc.nextLine sc int[] i = new int[M]; i new int[M] M for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		} int j = 0; int j = 0; j 0 j < i.length j i.length i i.length j++ j++ j {
			i[j] = 0;
		} {
			i[j] = 0;
		} i[j] = 0 i[j] i j 0 for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		} int k = 0; int k = 0; k 0 k < N k N k++ k++ k {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		} {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		} String s = sc.nextLine(); s sc.nextLine() sc.nextLine sc String[] split = s.split(" "); split s.split(" ") s.split s " " for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			} int l = 1; int l = 1; l 1 l < split.length l split.length split split.length l++ l++ l {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			} {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			} int a = Integer.parseInt(split[l])-1; a Integer.parseInt(split[l])-1 Integer.parseInt(split[l]) Integer.parseInt Integer split[l] split l 1 i[a]++ i[a] i a int res = 0; res 0 for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		} int n = 0; int n = 0; n 0 n <i.length n i.length i i.length n++ n++ n {
			if(i[n] == N) {
				res++;
			}
		} {
			if(i[n] == N) {
				res++;
			}
		} if(i[n] == N) {
				res++;
			} i[n] == N i[n] i n N {
				res++;
			} res++ res System.out.println(res) System.out.println System.out System System.out res 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 = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int M = Integer.parseInt(sc.nextLine().trim());
		
		int[] i = new int[M];
		
		for(int j = 0; j < i.length; j++) {
			i[j] = 0;
		}
		
		for(int k = 0; k < N; k++) {
			String s = sc.nextLine();
			String[] split = s.split(" ");
			
			for(int l = 1; l < split.length; l++) {
				int a = Integer.parseInt(split[l])-1;
				
				i[a]++;
			}
		}
		
		int res = 0;
		
		for(int n = 0; n <i.length; n++) {
			if(i[n] == N) {
				res++;
			}
		}
		System.out.println(res);
	}
}