import java.util.HashMap;
import java.util.Iterator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] input = scan.nextLine().split(" ");
		int n = Integer.parseInt(input[0]);
		int m = Integer.parseInt(input[1]);

		HashMap map = new HashMap<Integer, Integer>();
		for (int i=0; i<n; i++) {
			int foods = scan.nextInt();
			for (int j=0; j<foods; j++) {
				int food = scan.nextInt();
				if (map.containsKey(food)) {
						int suki = (int) map.get(food);
					map.put(food, ++suki);
				} else {
					map.put(food, 1);
				}
			}
		}

		int count = 0;
		for(Iterator it = map.keySet().iterator(); it.hasNext(); ) {
		    int key = (int) it.next();
		    int value = (int) map.get(key);

		    if (n == value) count++;
		}

		System.out.println(count);
	}
}
/tmp/hf-datasets-cache/medium/datasets/42704881117311-config-parquet-and-info-qiankunmu-Project_CodeNet-896c9d36/hub/datasets--qiankunmu--Project_CodeNet_Python800_and_Java250/snapshots/c899fde44a77ba1cc14973ed3de064e4ff3aadc7/Project_CodeNet_Java250.tar.gz