import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	} main {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	} Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int n = cin.nextInt(); n cin.nextInt() cin.nextInt cin int m = cin.nextInt(); m cin.nextInt() cin.nextInt cin int[] arr = new int[m + 1]; arr new int[m + 1] m + 1 m 1 for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		} {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		} int t = cin.nextInt(); t cin.nextInt() cin.nextInt cin for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			} int j = 0; int j = 0; j 0 j < t j t j++ j++ j {
				int idx = cin.nextInt();
				arr[idx]++;
			} {
				int idx = cin.nextInt();
				arr[idx]++;
			} int idx = cin.nextInt(); idx cin.nextInt() cin.nextInt cin arr[idx]++ arr[idx] arr idx int sum = 0; sum 0 for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++; int i = 1; int i = 1; i 1 i <= m i m i++ i++ i if (arr[i] == n)
				sum++; if (arr[i] == n)
				sum++; arr[i] == n arr[i] arr i n sum++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int n = cin.nextInt();
		int m = cin.nextInt();
		int[] arr = new int[m + 1];
		for (int i = 0; i < n; i++) {
			int t = cin.nextInt();
			for (int j = 0; j < t; j++) {
				int idx = cin.nextInt();
				arr[idx]++;
			}
		}
		int sum = 0;
		for (int i = 1; i <= m; i++) 
			if (arr[i] == n)
				sum++;
		System.out.println(sum);
	}
}