import java.util.Scanner;

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),M=sc.nextInt(),ans=0;
		int[] counter = new int[M+1];
		for(int i=0; i<N;i++) {
			int num = sc.nextInt();
			for(int j=0 ;j<num; j++) {
				counter[sc.nextInt()]++;
			}
		}
		for (int i : counter) {
			if(i == N) ans++;
		}
		System.out.println(ans);
	}
}
