import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	}
} import java.util.Arrays; Arrays java.util 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(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	} main {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int n = sc.nextInt() n sc.nextInt() sc.nextInt sc m = sc.nextInt(); m sc.nextInt() sc.nextInt sc int a = 0; a 0 int[] mkind = new int[m+1]; mkind new int[m+1] m+1 m 1 for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		} int i = 0; int i = 0; i 0 i < n i n i ++ i ++ i {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		} {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		} int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
				a = sc.nextInt();
				mkind[a]++;
			} {
				a = sc.nextInt();
				mkind[a]++;
			} a = sc.nextInt() a sc.nextInt() sc.nextInt sc mkind[a]++ mkind[a] mkind a int sum = 0; sum 0 for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		} int i = 0; int i = 0; i 0 i < m+1 i m+1 m 1 i ++ i ++ i {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		} {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		} if(mkind[i] == n) sum ++; mkind[i] == n mkind[i] mkind i n sum ++ sum System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	}
} Main
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(),m = sc.nextInt();
		int a = 0;
		int[] mkind = new int[m+1];
		for(int i = 0;i < n;i ++) {
			int k = sc.nextInt();
			for(int j = 0;j < k;j++) {
				a = sc.nextInt();
				mkind[a]++;
			}
		}
		//System.out.println(Arrays.toString(mkind));
		int sum = 0;
		for(int i = 0;i < m+1;i ++) {
			if(mkind[i] == n) sum ++;
			//System.out.println(mkind[i]);
		}
		System.out.println(sum);
	}
}