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