import java.util.Arrays;
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 answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	}
} import java.util.Arrays; Arrays java.util 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 answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	} 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 answerArr[] = new int[M]; answerArr new int[M] M int answer = 0; answer 0 Arrays.fill(answerArr, 0) Arrays.fill Arrays answerArr 0 for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 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++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		} {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		} int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			} {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			} int Ki = sc.nextInt(); Ki sc.nextInt() sc.nextInt sc answerArr[Ki - 1]++ answerArr[Ki - 1] answerArr Ki - 1 Ki 1 for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
			if (answerArr[i] == N) {
				answer++;
			}
		} {
			if (answerArr[i] == N) {
				answer++;
			}
		} if (answerArr[i] == N) {
				answer++;
			} answerArr[i] == N answerArr[i] answerArr i N {
				answer++;
			} answer++ answer System.out.println(answer) System.out.println System.out System System.out answer 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 answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	}
} Main
import java.util.Arrays;
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 answerArr[] = new int[M];
		int answer = 0;
		Arrays.fill(answerArr, 0);


		for (int i = 0; i < N; i++) {
			int K = sc.nextInt();
			for (int j = 0; j < K; j++) {
				int Ki = sc.nextInt();
				answerArr[Ki - 1]++;
			}
		}

		for (int i = 0; i < M; i++) {
			if (answerArr[i] == N) {
				answer++;
			}
		}

		System.out.println(answer);
	}
}
