import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	}
} Main public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	} main {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	} Scanner reader = new Scanner(System.in); reader new Scanner(System.in) int N = reader.nextInt(); N reader.nextInt() reader.nextInt reader int M = reader.nextInt(); M reader.nextInt() reader.nextInt reader int[] arr = new int[M]; arr new int[M] M for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		} {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		} int K = reader.nextInt(); K reader.nextInt() reader.nextInt reader for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			} int j = 0; int j = 0; j 0 j < K j K j++ j++ j {
				int num = reader.nextInt();
				arr[num - 1]++;
			} {
				int num = reader.nextInt();
				arr[num - 1]++;
			} int num = reader.nextInt(); num reader.nextInt() reader.nextInt reader arr[num - 1]++ arr[num - 1] arr num - 1 num 1 reader.close() reader.close reader int ans = 0; ans 0 for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < M i M i++ i++ i {
			if (arr[i] == N) {
				ans++;
			}
		} {
			if (arr[i] == N) {
				ans++;
			}
		} if (arr[i] == N) {
				ans++;
			} arr[i] == N arr[i] arr i N {
				ans++;
			} ans++ ans System.out.print(ans) System.out.print System.out System System.out ans String[] args args public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		int N = reader.nextInt();
		int M = reader.nextInt();
		int[] arr = new int[M];
		for (int i = 0; i < N; i++) {
			int K = reader.nextInt();
			for (int j = 0; j < K; j++) {
				int num = reader.nextInt();
				arr[num - 1]++;
			}
		}
		reader.close();
		int ans = 0;
		for (int i = 0; i < M; i++) {
			if (arr[i] == N) {
				ans++;
			}
		}
		System.out.print(ans);
	}
}

