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