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