import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] likes = new int[M+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} import java.util.Scanner; Scanner java.util public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] likes = new int[M+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main static Scanner sc = new Scanner(System.in); sc new Scanner(System.in) static int N = Integer.parseInt(sc.next()); N Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc static int M = Integer.parseInt(sc.next()); M Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc static int[] likes = new int[M+1]; likes new int[M+1] M+1 M 1 public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	} main {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	} for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		} {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		} int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			} int k = 0; int k = 0; k 0 k < K k K k++ k++ k {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			} {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			} int index = Integer.parseInt(sc.next()); index Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc likes[index]++ likes[index] likes index int ans = 0; ans 0 for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		} int i = 0; int i = 0; i 0 i <= M i M i++ i++ i {
			if (likes[i] == N) {
				ans++;
			}
		} {
			if (likes[i] == N) {
				ans++;
			}
		} if (likes[i] == N) {
				ans++;
			} likes[i] == N likes[i] likes i N {
				ans++;
			} ans++ ans System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] likes = new int[M+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] likes = new int[M+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
} Main
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] likes = new int[M+1];
	public static void main(String[] args) {
		for (int i = 0; i < N; i++) {
			int K = Integer.parseInt(sc.next());
			for (int k = 0; k < K; k++) {
				int index = Integer.parseInt(sc.next());
				likes[index]++;
			}
		}
		int ans = 0;
		for (int i = 0; i <= M; i++) {
			if (likes[i] == N) {
				ans++;
			}
		}
		System.out.println(ans);
	}
}
