import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	}
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main{
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	}
} Main static long mod = 1000000007; mod 1000000007 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == 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 M = sc.nextInt(); M sc.nextInt() sc.nextInt sc int[] eat = new int[M]; eat new int[M] M Arrays.fill(eat, 0) Arrays.fill Arrays eat 0 for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		} {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				int A = sc.nextInt() - 1;
				eat[A]++;
			} {
				int A = sc.nextInt() - 1;
				eat[A]++;
			} int A = sc.nextInt() - 1; A sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 eat[A]++ eat[A] eat A int ans = 0; ans 0 for(int i = 0; i < M; i++) if(eat[i] == N) ans++; int i = 0; int i = 0; i 0 i < M i M i++ i++ i if(eat[i] == N) ans++; if(eat[i] == N) ans++; eat[i] == N eat[i] eat i N ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	}
} public class Main{
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static long mod = 1000000007;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), M = sc.nextInt();
		int[] eat = new int[M];
		Arrays.fill(eat, 0);
		for(int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for(int j = 0; j < K; j++) {
				int A = sc.nextInt() - 1;
				eat[A]++;
			}
		}
		int ans = 0;
		for(int i = 0; i < M; i++) if(eat[i] == N) ans++;
		System.out.println(ans);
	}
}
