
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	}
} import java.util.ArrayList; ArrayList java.util import java.util.Iterator; Iterator java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	}
} Main public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	} main {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	} Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int N = scan.nextInt(); N scan.nextInt() scan.nextInt scan int M = scan.nextInt(); M scan.nextInt() scan.nextInt scan int[] favorite = new int[M]; favorite new int[M] M for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		} int i = 0; int i = 0; i 0 i < N i N i++ i++ i {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		} {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		} int num = scan.nextInt(); num scan.nextInt() scan.nextInt scan for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			} int j = 0; int j = 0; j 0 j < num j num j++ j++ j {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			} {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			} int fn = scan.nextInt(); fn scan.nextInt() scan.nextInt scan favorite[fn - 1]++ favorite[fn - 1] favorite fn - 1 fn 1 int count = 0; count 0 for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		} int i = 0; int i = 0; i 0 i < favorite.length i favorite.length favorite favorite.length i++ i++ i {
			if (favorite[i] == N) {
				count++;
			}
		} {
			if (favorite[i] == N) {
				count++;
			}
		} if (favorite[i] == N) {
				count++;
			} favorite[i] == N favorite[i] favorite i N {
				count++;
			} count++ count System.out.println(count) System.out.println System.out System System.out count scan.close() scan.close scan String[] args args public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	}
} public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	}
} Main

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int M = scan.nextInt();
		int[] favorite = new int[M];
		
		for (int i = 0; i < N; i++) {
			int num = scan.nextInt();
			for (int j = 0; j < num; j++) {
				int fn = scan.nextInt();
				favorite[fn - 1]++;
			}
		}
		
		int count = 0;
		for (int i = 0; i < favorite.length; i++) {
			if (favorite[i] == N) {
				count++;
			}
		}
		
		System.out.println(count);
		
		scan.close();
	}
}