import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	} main {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) StringBuilder sb = new StringBuilder(); sb new StringBuilder() int n = sc.nextInt(); n sc.nextInt() sc.nextInt sc int m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int[] a = new int[m]; a new int[m] m int k k idx idx cnt = 0; cnt 0 for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		} {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		} k = sc.nextInt() k sc.nextInt() sc.nextInt sc for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				idx = sc.nextInt() - 1;
				a[idx]++;
			} {
				idx = sc.nextInt() - 1;
				a[idx]++;
			} idx = sc.nextInt() - 1 idx sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 a[idx]++ a[idx] a idx for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			if (a[i] == n) {
				cnt++;
			}
		} {
			if (a[i] == n) {
				cnt++;
			}
		} if (a[i] == n) {
				cnt++;
			} a[i] == n a[i] a i n {
				cnt++;
			} cnt++ cnt System.out.println(cnt) System.out.println System.out System System.out cnt String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int k, idx, cnt = 0;
		for (int i = 0; i < n; i++) {
			k = sc.nextInt();
			for (int j = 0; j < k; j++) {
				idx = sc.nextInt() - 1;
				a[idx]++;
			}
		}

		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}
