import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} import java.util.Scanner; Scanner java.util public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} Main public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = Integer.parseInt(sc.next()); n Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int m = Integer.parseInt(sc.next()); m Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int[] result = new int[m]; result new int[m] m for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		} {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		} int k = Integer.parseInt(sc.next()); k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				result[Integer.parseInt(sc.next()) - 1]++;
			} {
				result[Integer.parseInt(sc.next()) - 1]++;
			} result[Integer.parseInt(sc.next()) - 1]++ result[Integer.parseInt(sc.next()) - 1] result Integer.parseInt(sc.next()) - 1 Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc 1 int ans = 0; ans 0 for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i < result.length i result.length result result.length i++ i++ i {
			if (result[i] == n) {
				ans++;
			}
		} {
			if (result[i] == n) {
				ans++;
			}
		} if (result[i] == n) {
				ans++;
			} result[i] == n result[i] result i n {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans sc.close() sc.close sc String[] args args public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
} Main
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int[] result = new int[m];
		for (int i = 0; i < n; i++) {
			int k = Integer.parseInt(sc.next());
			for (int j = 0; j < k; j++) {
				result[Integer.parseInt(sc.next()) - 1]++;
			}
		}
		int ans = 0;
		for (int i = 0; i < result.length; i++) {
			if (result[i] == n) {
				ans++;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}