import 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[n][m];
		int[] numoflover = new int[m];
		int answer = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		}
		for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1;
		System.out.println(answer);
	}

} import java.util.*; util.* java 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[n][m];
		int[] numoflover = new int[m];
		int answer = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		}
		for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1;
		System.out.println(answer);
	}

} 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[n][m];
		int[] numoflover = new int[m];
		int answer = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		}
		for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1;
		System.out.println(answer);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] a = new int[n][m];
		int[] numoflover = new int[m];
		int answer = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		}
		for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1;
		System.out.println(answer);
	} 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[n][m]; a new int[n][m] n m int[] numoflover = new int[m]; numoflover new int[m] m int answer = 0; answer 0 for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		} {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		} int num = sc.nextInt(); num sc.nextInt() sc.nextInt sc for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			} int j = 0; int j = 0; j 0 j < num j num j++ j++ j {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			} {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			} a[i][j] = sc.nextInt() a[i][j] a[i] a i j sc.nextInt() sc.nextInt sc for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1; int k = 0; int k = 0; k 0 k < m k m k++ k++ k if(a[i][j] == k+1)
						numoflover[k] += 1; if(a[i][j] == k+1)
						numoflover[k] += 1; a[i][j] == k+1 a[i][j] a[i] a i j k+1 k 1 numoflover[k] += 1 numoflover[k] numoflover k 1 for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1; int j = 0; int j = 0; j 0 j < m j m j++ j++ j if(numoflover[j] == n) answer += 1; if(numoflover[j] == n) answer += 1; numoflover[j] == n numoflover[j] numoflover j n answer += 1 answer 1 System.out.println(answer) System.out.println System.out System System.out answer 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[n][m];
		int[] numoflover = new int[m];
		int answer = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		}
		for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1;
		System.out.println(answer);
	}

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

} Main
import 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[n][m];
		int[] numoflover = new int[m];
		int answer = 0;
		for(int i = 0; i < n; i++) {
			int num = sc.nextInt();
			for(int j = 0; j < num; j++) {
				a[i][j] = sc.nextInt();
				for(int k = 0; k < m; k++)
					if(a[i][j] == k+1)
						numoflover[k] += 1;
			}
		}
		for(int j = 0; j < m; j++)
			if(numoflover[j] == n) answer += 1;
		System.out.println(answer);
	}

}