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);
	}
} import java.util.HashMap; HashMap java.util import java.util.Iterator; Iterator java.util import java.util.Scanner; Scanner java.util 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);
	}
} 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);
	} main {
		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);
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) String[] input = scan.nextLine().split(" "); input scan.nextLine().split(" ") scan.nextLine().split scan.nextLine() scan.nextLine scan " " int n = Integer.parseInt(input[0]); n Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int m = Integer.parseInt(input[1]); m Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 HashMap map = new HashMap<Integer, Integer>(); 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 i=0; int i=0; i 0 i<n i n i++ i++ 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 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 foods = scan.nextInt(); foods scan.nextInt() scan.nextInt scan 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 j=0; int j=0; j 0 j<foods j foods j++ j++ 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 food = scan.nextInt();
				if (map.containsKey(food)) {
						int suki = (int) map.get(food);
					map.put(food, ++suki);
				} else {
					map.put(food, 1);
				}
			} int food = scan.nextInt(); food scan.nextInt() scan.nextInt scan if (map.containsKey(food)) {
						int suki = (int) map.get(food);
					map.put(food, ++suki);
				} else {
					map.put(food, 1);
				} map.containsKey(food) map.containsKey map food {
						int suki = (int) map.get(food);
					map.put(food, ++suki);
				} int suki = (int) map.get(food); suki (int) map.get(food) map.get map food map.put(food, ++suki) map.put map food ++suki suki {
					map.put(food, 1);
				} map.put(food, 1) map.put map food 1 int count = 0; 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++;
		} Iterator it = map.keySet().iterator(); Iterator it = map.keySet().iterator(); it map.keySet().iterator() map.keySet().iterator map.keySet() map.keySet map it.hasNext() it.hasNext it {
		    int key = (int) it.next();
		    int value = (int) map.get(key);

		    if (n == value) count++;
		} {
		    int key = (int) it.next();
		    int value = (int) map.get(key);

		    if (n == value) count++;
		} int key = (int) it.next(); key (int) it.next() it.next it int value = (int) map.get(key); value (int) map.get(key) map.get map key if (n == value) count++; n == value n value count++ count System.out.println(count) System.out.println System.out System System.out count String[] args args 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);
	}
} 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);
	}
} Main
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);
	}
}