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[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	}
} 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[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	}
} Main public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	} main {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	} 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[] a = new int[m]; a new int[m] m for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		} {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		} int tmp = sc.nextInt(); tmp sc.nextInt() sc.nextInt sc for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			} int j = 0; int j = 0; j 0 j < tmp j tmp j++ j++ j {
				a[sc.nextInt() - 1]++;
			} {
				a[sc.nextInt() - 1]++;
			} a[sc.nextInt() - 1]++ a[sc.nextInt() - 1] a sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 int count = 0; count 0 for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < m i m i++ i++ i {
			if (a[i] == n) {
				count++;
			}
		} {
			if (a[i] == n) {
				count++;
			}
		} if (a[i] == n) {
				count++;
			} a[i] == n a[i] a i n {
				count++;
			} count++ count System.out.print(count) System.out.print System.out System System.out count 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[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	}
} public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	}
} Main
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[] a = new int[m];

		for (int i = 0; i < n; i++) {
			int tmp = sc.nextInt();
			for (int j = 0; j < tmp; j++) {
				a[sc.nextInt() - 1]++;
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (a[i] == n) {
				count++;
			}
		}

		System.out.print(count);
	}
}