import java.util.Scanner;

public 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];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	}

} 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();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	}

} 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];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] K = new int[N];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	} 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 int[] A = new int[M+1]; A new int[M+1] M+1 M 1 int a = 0; a 0 for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		} 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 b = sc.nextInt();
				A[b]++;
			}
		} {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		} K[i] = sc.nextInt() K[i] K i sc.nextInt() sc.nextInt sc for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			} int j=0; int j=0; j 0 j<K[i] j K[i] K i j++ j++ j {
				int b = sc.nextInt();
				A[b]++;
			} {
				int b = sc.nextInt();
				A[b]++;
			} int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc A[b]++ A[b] A b sc.close() sc.close sc for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		} int i=1; int i=1; i 1 i<=M i M i++ i++ i {
			if(A[i] == N) {
				a++;
			}
		} {
			if(A[i] == N) {
				a++;
			}
		} if(A[i] == N) {
				a++;
			} A[i] == N A[i] A i N {
				a++;
			} a++ a System.out.println(a) System.out.println System.out System System.out a String[] args args public 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];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	}

} public 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];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	}

} Main
import java.util.Scanner;

public 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];
		int[] A = new int[M+1];
		int a = 0;
		for(int i=0; i<N; i++) {
			K[i] = sc.nextInt();
			for(int j=0; j<K[i]; j++) {
				int b = sc.nextInt();
				A[b]++;
			}
		}
		sc.close();
		for(int i=1; i<=M; i++) {
			if(A[i] == N) {
				a++;
			}
		}
		System.out.println(a);
	}

}