import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    }
} Main public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    } main {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) String[] nm  = in.nextLine().split(" "); nm in.nextLine().split(" ") in.nextLine().split in.nextLine() in.nextLine in " " int n n m; m n = Integer.parseInt(nm[0]) n Integer.parseInt(nm[0]) Integer.parseInt Integer nm[0] nm 0 m = Integer.parseInt(nm[1]) m Integer.parseInt(nm[1]) Integer.parseInt Integer nm[1] nm 1 int[] likeFoods = new int[m]; likeFoods new int[m] m for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	} int i = 0; int i = 0; i 0 i < n i n i++ i++ i {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	} {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	} int k = in.nextInt(); k in.nextInt() in.nextInt in for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		} int j = 0; int j = 0; j 0 j < k j k j++ j++ j {
    			likeFoods[in.nextInt()-1]++;
    		} {
    			likeFoods[in.nextInt()-1]++;
    		} likeFoods[in.nextInt()-1]++ likeFoods[in.nextInt()-1] likeFoods in.nextInt()-1 in.nextInt() in.nextInt in 1 int counter = 0; counter 0 for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	} int foods likeFoods {
    		if (foods == n) {
    			counter++;
    		}
    	} {
    		if (foods == n) {
    			counter++;
    		}
    	} if (foods == n) {
    			counter++;
    		} foods == n foods n {
    			counter++;
    		} counter++ counter System.out.println(counter) System.out.println System.out System System.out counter String[] args args public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    }
} public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	String[] nm  = in.nextLine().split(" ");
    	int n, m;
    	n = Integer.parseInt(nm[0]);
    	m = Integer.parseInt(nm[1]);
    	int[] likeFoods = new int[m];
    	
    	for (int i = 0; i < n; i++) {
    		int k = in.nextInt();
    		for (int j = 0; j < k; j++) {
    			likeFoods[in.nextInt()-1]++;
    		}
    	}
    	
    	int counter = 0;
    	for (int foods: likeFoods) {
    		if (foods == n) {
    			counter++;
    		}
    	}
    	
    	System.out.println(counter);
    	
    	
    }
}
